diff --git a/InvenTree/part/templates/part/detail.html b/InvenTree/part/templates/part/detail.html
index 670d10cf34..44f6682d3c 100644
--- a/InvenTree/part/templates/part/detail.html
+++ b/InvenTree/part/templates/part/detail.html
@@ -309,6 +309,7 @@
@@ -514,6 +518,7 @@
// Load the "builds" tab
onPanelLoad("build-orders", function() {
+ {% if part.assembly %}
$("#start-build").click(function() {
newBuildOrder({
part: {{ part.pk }},
@@ -526,12 +531,15 @@
part: {{ part.id }},
}
});
+ {% endif %}
+ {% if part.component %}
loadBuildOrderAllocationTable("#build-order-allocation-table", {
params: {
part: {{ part.id }},
}
});
+ {% endif %}
});
diff --git a/InvenTree/stock/templates/stock/item.html b/InvenTree/stock/templates/stock/item.html
index 113fefb9b1..648896276d 100644
--- a/InvenTree/stock/templates/stock/item.html
+++ b/InvenTree/stock/templates/stock/item.html
@@ -37,19 +37,36 @@
+
+ {% if item.part.component %}
-
{% trans "Stock Item Allocations" %}
+ {% trans "Build Order Allocations" %}
{% include "spacer.html" %}
-
+ {% endif %}
+ {% if item.part.salable %}
+
+
{% trans "Sales Order Allocations" %}
+ {% include "spacer.html" %}
+
+
+ {% endif %}
@@ -164,14 +181,21 @@
// Load the "allocations" tab
onPanelLoad('allocations', function() {
- loadStockAllocationTable(
- $("#stock-allocation-table"),
- {
- params: {
- stock_item: {{ item.pk }},
- },
+ {% if item.part.component %}
+ loadBuildOrderAllocationTable('#build-order-allocation-table', {
+ params: {
+ stock_item: {{ item.pk }},
}
- );
+ });
+ {% endif %}
+
+ {% if item.part.salable %}
+ loadSalesOrderAllocationTable('#sales-order-allocation-table', {
+ params: {
+ stock_item: {{ item.pk }},
+ }
+ });
+ {% endif %}
});
$('#stock-item-install').click(function() {
diff --git a/InvenTree/templates/js/translated/stock.js b/InvenTree/templates/js/translated/stock.js
index 3cbf6d7634..b7f4162621 100644
--- a/InvenTree/templates/js/translated/stock.js
+++ b/InvenTree/templates/js/translated/stock.js
@@ -46,7 +46,6 @@
findStockItemBySerialNumber,
installStockItem,
loadInstalledInTable,
- loadStockAllocationTable,
loadStockLocationTable,
loadStockTable,
loadStockTestResultsTable,
@@ -2302,161 +2301,6 @@ function loadStockTable(table, options) {
}
-/*
- * Display a table of allocated stock, for either a part or stock item
- * Allocations are displayed for:
- *
- * a) Sales Orders
- * b) Build Orders
- */
-function loadStockAllocationTable(table, options={}) {
-
- var params = options.params || {};
-
- params.build_detail = true;
-
- var filterListElement = options.filterList || '#filter-list-allocations';
-
- var filters = {};
-
- var filterKey = options.filterKey || options.name || 'allocations';
-
- var original = {};
-
- for (var k in params) {
- original[k] = params[k];
- filters[k] = params[k];
- }
-
- setupFilterList(filterKey, table, filterListElement);
-
- /*
- * We have two separate API queries to make here:
- * a) Build Order Allocations
- * b) Sales Order Allocations
- *
- * We will let the call to inventreeTable take care of build orders,
- * and then load sales orders after that.
- */
- table.inventreeTable({
- url: '{% url "api-build-item-list" %}',
- name: 'allocations',
- original: original,
- method: 'get',
- queryParams: filters,
- sidePagination: 'client',
- showColumns: false,
- onLoadSuccess: function(tableData) {
-
- var query_params = params;
-
- query_params.customer_detail = true;
- query_params.order_detail = true;
-
- // Note: SalesOrderAllocations do not get deleted,
- // so we must filter by "outstanding" status
- query_params.outstanding = true;
-
- delete query_params.build_detail;
-
- // Load sales order allocation data
- inventreeGet('{% url "api-so-allocation-list" %}', query_params, {
- success: function(data) {
- // Update table to include sales order data
- $(table).bootstrapTable('append', data);
- }
- });
- },
- columns: [
- {
- field: 'order',
- title: '{% trans "Order" %}',
- formatter: function(value, row) {
-
- var html = '';
-
- if (row.build) {
-
- // Add an icon for the part being built
- html += thumbnailImage(row.build_detail.part_detail.thumbnail, {
- title: row.build_detail.part_detail.full_name
- });
-
- html += ' ';
-
- html += renderLink(
- global_settings.BUILDORDER_REFERENCE_PREFIX + row.build_detail.reference,
- `/build/${row.build}/`
- );
-
- html += makeIconBadge('fa-tools', '{% trans "Build Order" %}');
- } else if (row.order) {
-
- // Add an icon for the customer
- html += thumbnailImage(row.customer_detail.thumbnail || row.customer_detail.image, {
- title: row.customer_detail.name,
- });
-
- html += ' ';
-
- html += renderLink(
- global_settings.SALESORDER_REFERENCE_PREFIX + row.order_detail.reference,
- `/order/sales-order/${row.order}/`
- );
- html += makeIconBadge('fa-truck', '{% trans "Sales Order" %}');
- } else {
- return '-';
- }
-
- return html;
- }
- },
- {
- field: 'description',
- title: '{% trans "Description" %}',
- formatter: function(value, row) {
- if (row.order_detail) {
- return row.order_detail.description;
- } else if (row.build_detail) {
- return row.build_detail.title;
- } else {
- return '-';
- }
- }
- },
- {
- field: 'status',
- title: '{% trans "Order Status" %}',
- formatter: function(value, row) {
- if (row.build) {
- return buildStatusDisplay(row.build_detail.status);
- } else if (row.order) {
- return salesOrderStatusDisplay(row.order_detail.status);
- } else {
- return '-';
- }
- }
- },
- {
- field: 'quantity',
- title: '{% trans "Allocated Quantity" %}',
- formatter: function(value, row) {
- var text = value;
- var pk = row.stock_item || row.item;
-
- if (pk) {
- var url = `/stock/item/${pk}/`;
- return renderLink(text, url);
- } else {
- return value;
- }
- }
- },
- ]
- });
-}
-
-
/*
* Display a table of stock locations
*/