From 42c1210fbabc0cac6a2d60fc23110232c0f75777 Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Sat, 24 Oct 2020 13:16:43 +1100 Subject: [PATCH] Calculate required build quantity --- InvenTree/templates/js/build.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/InvenTree/templates/js/build.js b/InvenTree/templates/js/build.js index 1c68677768..e4c911634f 100644 --- a/InvenTree/templates/js/build.js +++ b/InvenTree/templates/js/build.js @@ -190,10 +190,6 @@ function loadBuildOutputAllocationTable(buildId, partId, output, options={}) { // Primary key of the 'sub_part' var pk = $(this).attr('pk'); - // Extract row data from the table - //var idx = $(this).closest('tr').attr('data-index'); - //var row = $(table).bootstrapTable('getData')[idx]; - // Launch form to allocate new stock against this output launchModalForm("{% url 'build-item-create' %}", { success: reloadTable, @@ -220,13 +216,17 @@ function loadBuildOutputAllocationTable(buildId, partId, output, options={}) { $(table).find('.button-build').click(function() { var pk = $(this).attr('pk'); + // Extract row data from the table + var idx = $(this).closest('tr').attr('data-index'); + var row = $(table).bootstrapTable('getData')[idx]; + // Launch form to create a new build order launchModalForm('{% url "build-create" %}', { follow: true, data: { part: pk, parent: buildId, - quantity: 123, // TODO - Fix this quantity! + quantity: requiredQuantity(row) - sumAllocations(row), } }); });