Load and display build order allocation items via AJAX

This commit is contained in:
Oliver 2021-06-18 19:18:35 +10:00
parent 245c9bfd28
commit 778aa0314d
5 changed files with 33 additions and 42 deletions

View File

@ -8,43 +8,30 @@
{% endblock %}
{% block heading %}
{% trans "Part Stock Allocations" %}
{% trans "Build Order Allocations" %}
{% endblock %}
{% block details %}
<h4>{% trans "Build Order Allocations" %}</h4>
<table class='table table-striped table-condensed' id='build-order-table'></table>
<h4>{% trans "Sales Order Allocations" %}</h4>
{% endblock %}
<table class='table table-striped table-condensed' id='sales-order-table'></table>
{% block pre_content_panel %}
<table class='table table-striped table-condensed' id='build-table'>
<tr>
<th>{% trans "Order" %}</th>
<th>{% trans "Stock Item" %}</th>
<th>{% trans "Quantity" %}</th>
</tr>
{% for allocation in part.build_order_allocations %}
<tr>
<td><a href="{% url 'build-detail' allocation.build.id %}">{% trans "Build Order" %}: {{ allocation.build }}</a></td>
<td><a href="{% url 'stock-item-detail' allocation.stock_item.id %}">{% trans "Stock Item" %}: {{ allocation.stock_item }}</a></td>
<td>{% decimal allocation.quantity %}</td>
</tr>
{% endfor %}
{% for allocation in part.sales_order_allocations %}
<tr>
<td><a href="{% url 'so-detail' allocation.line.order.id %}">{% trans "Sales Order" %}: {{ allocation.line.order }}</a></td>
<td><a href="{% url 'stock-item-detail' allocation.item.id %}">{% trans "Stock Item" %}: {{ allocation.item }}</a></td>
<td>{% decimal allocation.quantity %}</td>
</tr>
{% endfor %}
</table>
<div class='panel panel-default panel-inventree'>
<div class='panel-heading'>
<h4>{% trans "Sales Order Allocations" %}</h4>
</div>
<div class='panel-content'>
<table class='table table-striped table-condensed' id='sales-order-table'></table>
</div>
</div>
{% endblock %}
{% block js_ready %}
{{ block.super }}
@ -54,21 +41,10 @@
}
});
$("#build-table").inventreeTable({
columns: [
{
title: '{% trans "Order" %}',
sortable: true,
},
{
title: '{% trans "Stock Item" %}',
sortable: true,
},
{
title: '{% trans "Quantity" %}',
sortable: true,
}
]
loadBuildOrderAllocationTable("#build-order-table", {
params: {
part: {{ part.id }},
}
});
{% endblock %}

View File

@ -195,8 +195,13 @@
</div>
{% block pre_content_panel %}
{% endblock %}
<div class='panel panel-default panel-inventree'>
<div class='panel-heading'>
<h4>
{% block heading %}
@ -210,7 +215,11 @@
<!-- Specific part details go here... -->
{% endblock %}
</div>
</div>
{% block post_content_panel %}
{% endblock %}
{% endblock %}

View File

@ -177,6 +177,8 @@ function loadBuildOrderAllocationTable(table, options={}) {
queryParams: filters,
name: 'buildorderallocation',
groupBy: false,
search: false,
paginationVAlign: 'bottom',
original: options.params,
formatNoMatches: function() {
return '{% trans "No build order allocations found" %}'
@ -189,6 +191,7 @@ function loadBuildOrderAllocationTable(table, options={}) {
},
{
field: 'build',
switchable: false,
title: '{% trans "Build Order" %}',
formatter: function(value, row) {
var prefix = "{% settings_value 'BUILDORDER_REFERENCE_PREFIX' %}";

View File

@ -337,6 +337,8 @@ function loadSalesOrderAllocationTable(table, options={}) {
queryParams: filters,
name: 'salesorderallocation',
groupBy: false,
search: false,
paginationVAlign: 'bottom',
original: options.params,
formatNoMatches: function() { return '{% trans "No sales order allocations found" %}'; },
columns: [
@ -347,6 +349,7 @@ function loadSalesOrderAllocationTable(table, options={}) {
},
{
field: 'order',
switchable: false,
title: '{% trans "Order" %}',
switchable: false,
formatter: function(value, row) {

View File

@ -135,7 +135,7 @@ $.fn.inventreeTable = function(options) {
// Pagingation options (can be server-side or client-side as specified by the caller)
options.pagination = true;
options.paginationVAlign = 'both';
options.paginationVAlign = options.paginationVAlign || 'both';
options.pageSize = inventreeLoad(varName, 25);
options.pageList = [25, 50, 100, 250, 'all'];
options.totalField = 'count';