diff --git a/InvenTree/build/templates/build/detail.html b/InvenTree/build/templates/build/detail.html index d715149718..b7cdf12921 100644 --- a/InvenTree/build/templates/build/detail.html +++ b/InvenTree/build/templates/build/detail.html @@ -308,40 +308,55 @@ loadStockTable($("#build-stock-table"), { url: "{% url 'api-stock-list' %}", }); -var buildInfo = { - pk: {{ build.pk }}, - quantity: {{ build.quantity }}, - completed: {{ build.completed }}, - part: {{ build.part.pk }}, - {% 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 %} -}; -{% if build.active %} -loadBuildOutputTable( - buildInfo, +// Get the list of BOM items required for this build +inventreeGet( + '{% url "api-bom-list" %}', { - - } -); -{% endif %} - -{% for item in build.incomplete_outputs %} -// Get the build output as a javascript object -inventreeGet('{% url 'api-stock-detail' item.pk %}', {}, + part: {{ build.part.pk }}, + sub_part_detail: true, + }, { success: function(response) { - loadBuildOutputAllocationTable(buildInfo, response); + + 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 %} + }; + + {% if build.active %} + loadBuildOutputTable(build_info); + {% endif %} + + {% for item in build.incomplete_outputs %} + // Get the build output as a javascript object + inventreeGet('{% url 'api-stock-detail' item.pk %}', {}, + { + success: function(response) { + loadBuildOutputAllocationTable(build_info, response); + } + } + ); + {% endfor %} + + {% if build.has_untracked_bom_items %} + // Load allocation table for un-tracked parts + loadBuildOutputAllocationTable(build_info, null); + {% endif %} + } } ); -{% endfor %} loadBuildTable($('#sub-build-table'), { url: '{% url "api-build-list" %}', @@ -351,6 +366,7 @@ loadBuildTable($('#sub-build-table'), { } }); + enableDragAndDrop( '#attachment-dropzone', '{% url "api-build-attachment-list" %}', @@ -425,11 +441,6 @@ $('#edit-notes').click(function() { }); }); -{% if build.has_untracked_bom_items %} -// Load allocation table for un-tracked parts -loadBuildOutputAllocationTable(buildInfo, null); -{% endif %} - function reloadTable() { $('#allocation-table-untracked').bootstrapTable('refresh'); } diff --git a/InvenTree/templates/js/translated/build.js b/InvenTree/templates/js/translated/build.js index 4d8637d7ca..7c0185ec8b 100644 --- a/InvenTree/templates/js/translated/build.js +++ b/InvenTree/templates/js/translated/build.js @@ -428,6 +428,15 @@ 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 = []; + + build_info.bom_items.forEach(function(bom_item) { + if (bom_item.sub_part_detail.trackable) { + tracked_bom_items.push(bom_item); + }; + }); + var filters = {}; for (var key in params) { @@ -488,6 +497,83 @@ function loadBuildOutputTable(build_info, options={}) { }); } + /* + * Construct a "sub table" showing the required BOM items + */ + function constructBuildOutputSubTable(index, row, element) { + var sub_table_id = `output-sub-table-${row.pk}`; + + var html = ` +