From 8fc34a21a6b7be239c00743ce3e14a91ecd52669 Mon Sep 17 00:00:00 2001 From: Oliver Date: Fri, 29 Apr 2022 12:59:20 +1000 Subject: [PATCH] Reload the untracked stock table when allocation actions are performed --- InvenTree/build/templates/build/detail.html | 52 ++++++++++++--------- InvenTree/templates/js/translated/build.js | 4 +- 2 files changed, 32 insertions(+), 24 deletions(-) diff --git a/InvenTree/build/templates/build/detail.html b/InvenTree/build/templates/build/detail.html index 52b81e6389..42bc51bb2f 100644 --- a/InvenTree/build/templates/build/detail.html +++ b/InvenTree/build/templates/build/detail.html @@ -431,24 +431,32 @@ onPanelLoad('outputs', function() { {% 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, -}; +function loadUntrackedStockTable() { + + 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, + }; + + $('#allocation-table-untracked').bootstrapTable('destroy'); + + // Load allocation table for un-tracked parts + loadBuildOutputAllocationTable( + build_info, + null, + { + search: true, + } + ); +} + +loadUntrackedStockTable(); -// Load allocation table for un-tracked parts -loadBuildOutputAllocationTable( - build_info, - null, - { - search: true, - } -); {% endif %} $('#btn-create-output').click(function() { @@ -472,6 +480,7 @@ $("#btn-auto-allocate").on('click', function() { {% if build.take_from %} location: {{ build.take_from.pk }}, {% endif %} + onSuccess: loadUntrackedStockTable, } ); }); @@ -503,9 +512,7 @@ $("#btn-allocate").on('click', function() { {% if build.take_from %} source_location: {{ build.take_from.pk }}, {% endif %} - success: function(data) { - $('#allocation-table-untracked').bootstrapTable('refresh'); - } + success: loadUntrackedStockTable, } ); } @@ -514,6 +521,7 @@ $("#btn-allocate").on('click', function() { $('#btn-unallocate').on('click', function() { unallocateStock({{ build.id }}, { table: '#allocation-table-untracked', + onSuccess: loadUntrackedStockTable, }); }); @@ -533,9 +541,7 @@ $('#allocate-selected-items').click(function() { {% if build.take_from %} source_location: {{ build.take_from.pk }}, {% endif %} - success: function(data) { - $('#allocation-table-untracked').bootstrapTable('refresh'); - } + success: loadUntrackedStockTable, } ); }); diff --git a/InvenTree/templates/js/translated/build.js b/InvenTree/templates/js/translated/build.js index a88f3ccb28..a8a973d516 100644 --- a/InvenTree/templates/js/translated/build.js +++ b/InvenTree/templates/js/translated/build.js @@ -2270,7 +2270,9 @@ function autoAllocateStockToBuild(build_id, bom_items=[], options={}) { confirm: true, preFormContent: html, onSuccess: function(response) { - $('#allocation-table-untracked').bootstrapTable('refresh'); + if (options.onSuccess) { + options.onSuccess(response); + } } }); }