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

View File

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

View File

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

View File

@ -337,6 +337,8 @@ function loadSalesOrderAllocationTable(table, options={}) {
queryParams: filters, queryParams: filters,
name: 'salesorderallocation', name: 'salesorderallocation',
groupBy: false, groupBy: false,
search: false,
paginationVAlign: 'bottom',
original: options.params, original: options.params,
formatNoMatches: function() { return '{% trans "No sales order allocations found" %}'; }, formatNoMatches: function() { return '{% trans "No sales order allocations found" %}'; },
columns: [ columns: [
@ -347,6 +349,7 @@ function loadSalesOrderAllocationTable(table, options={}) {
}, },
{ {
field: 'order', field: 'order',
switchable: false,
title: '{% trans "Order" %}', title: '{% trans "Order" %}',
switchable: false, switchable: false,
formatter: function(value, row) { 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) // Pagingation options (can be server-side or client-side as specified by the caller)
options.pagination = true; options.pagination = true;
options.paginationVAlign = 'both'; options.paginationVAlign = options.paginationVAlign || 'both';
options.pageSize = inventreeLoad(varName, 25); options.pageSize = inventreeLoad(varName, 25);
options.pageList = [25, 50, 100, 250, 'all']; options.pageList = [25, 50, 100, 250, 'all'];
options.totalField = 'count'; options.totalField = 'count';