diff --git a/InvenTree/build/templates/build/detail.html b/InvenTree/build/templates/build/detail.html index 92e1177e0f..c01c9055f1 100644 --- a/InvenTree/build/templates/build/detail.html +++ b/InvenTree/build/templates/build/detail.html @@ -401,110 +401,107 @@ function reloadTable() { $('#allocation-table-untracked').bootstrapTable('refresh'); } -// Get the list of BOM items required for this build -inventreeGet( - '{% url "api-bom-list" %}', - { +onPanelLoad('outputs', function() { + {% if build.active %} + + var build_info = { + pk: {{ build.pk }}, part: {{ build.part.pk }}, - sub_part_detail: true, - }, - { - success: function(response) { + quantity: {{ build.quantity }}, + {% if build.take_from %} + source_location: {{ build.take_from.pk }}, + {% endif %} + tracked_parts: true, + }; - var build_info = { - pk: {{ build.pk }}, - part: {{ build.part.pk }}, - quantity: {{ build.quantity }}, - bom_items: response, - {% if build.take_from %} - source_location: {{ build.take_from.pk }}, - {% endif %} - {% if build.has_tracked_bom_items %} - tracked_parts: true, - {% else %} - tracked_parts: false, - {% endif %} - }; + loadBuildOutputTable(build_info); - {% if build.active %} - loadBuildOutputTable(build_info); - linkButtonsToSelection( - '#build-output-table', - [ - '#output-options', - '#multi-output-complete', - '#multi-output-delete', - ] - ); + linkButtonsToSelection( + '#build-output-table', + [ + '#output-options', + '#multi-output-complete', + '#multi-output-delete', + ] + ); - $('#multi-output-complete').click(function() { - var outputs = $('#build-output-table').bootstrapTable('getSelections'); + $('#multi-output-complete').click(function() { + var outputs = $('#build-output-table').bootstrapTable('getSelections'); - completeBuildOutputs( - build_info.pk, - outputs, - { - success: function() { - // Reload the "in progress" table - $('#build-output-table').bootstrapTable('refresh'); + completeBuildOutputs( + build_info.pk, + outputs, + { + success: function() { + // Reload the "in progress" table + $('#build-output-table').bootstrapTable('refresh'); - // Reload the "completed" table - $('#build-stock-table').bootstrapTable('refresh'); - } - } - ); - }); - - $('#multi-output-delete').click(function() { - var outputs = $('#build-output-table').bootstrapTable('getSelections'); - - deleteBuildOutputs( - build_info.pk, - outputs, - { - success: function() { - // Reload the "in progress" table - $('#build-output-table').bootstrapTable('refresh'); - - // Reload the "completed" table - $('#build-stock-table').bootstrapTable('refresh'); - } - } - ) - }); - - $('#incomplete-output-print-label').click(function() { - var outputs = $('#build-output-table').bootstrapTable('getSelections'); - - if (outputs.length == 0) { - outputs = $('#build-output-table').bootstrapTable('getData'); + // Reload the "completed" table + $('#build-stock-table').bootstrapTable('refresh'); } + } + ); + }); - var stock_id_values = []; + $('#multi-output-delete').click(function() { + var outputs = $('#build-output-table').bootstrapTable('getSelections'); - outputs.forEach(function(output) { - stock_id_values.push(output.pk); - }); + deleteBuildOutputs( + build_info.pk, + outputs, + { + success: function() { + // Reload the "in progress" table + $('#build-output-table').bootstrapTable('refresh'); - printStockItemLabels(stock_id_values); - - }); - - {% endif %} - - {% if build.active and build.has_untracked_bom_items %} - // Load allocation table for un-tracked parts - loadBuildOutputAllocationTable( - build_info, - null, - { - search: true, + // Reload the "completed" table + $('#build-stock-table').bootstrapTable('refresh'); } - ); - {% endif %} + } + ) + }); + + $('#incomplete-output-print-label').click(function() { + var outputs = $('#build-output-table').bootstrapTable('getSelections'); + + if (outputs.length == 0) { + outputs = $('#build-output-table').bootstrapTable('getData'); } + + var stock_id_values = []; + + outputs.forEach(function(output) { + stock_id_values.push(output.pk); + }); + + printStockItemLabels(stock_id_values); + + }); + + {% endif %} +}); + +{% if build.active and build.has_untracked_bom_items %} + +var build_info = { + pk: {{ build.pk }}, + part: {{ build.part.pk }}, + quantity: {{ build.quantity }}, + {% if build.take_from %} + source_location: {{ build.take_from.pk }}, + {% endif %} + tracked_parts: false, +}; + +// Load allocation table for un-tracked parts +loadBuildOutputAllocationTable( + build_info, + null, + { + search: true, } ); +{% endif %} $('#btn-create-output').click(function() { diff --git a/InvenTree/templates/js/translated/build.js b/InvenTree/templates/js/translated/build.js index 29683154fe..b90837a231 100644 --- a/InvenTree/templates/js/translated/build.js +++ b/InvenTree/templates/js/translated/build.js @@ -741,18 +741,6 @@ function loadBuildOutputTable(build_info, options={}) { params.is_building = true; params.build = build_info.pk; - // Construct a list of "tracked" BOM items - var tracked_bom_items = []; - - var has_tracked_items = false; - - build_info.bom_items.forEach(function(bom_item) { - if (bom_item.sub_part_detail.trackable) { - tracked_bom_items.push(bom_item); - has_tracked_items = true; - }; - }); - var filters = {}; for (var key in params) { @@ -1031,7 +1019,7 @@ function loadBuildOutputTable(build_info, options={}) { sortable: true, search: false, sidePagination: 'client', - detailView: has_tracked_items, + detailView: true, detailFilter: function(index, row) { return true; }, @@ -1105,7 +1093,7 @@ function loadBuildOutputTable(build_info, options={}) { { field: 'allocated', title: '{% trans "Allocated Stock" %}', - visible: has_tracked_items, + visible: true, switchable: false, formatter: function(value, row) { return `
`;