From 53e442f5552688307a98428ce12ec02e56499063 Mon Sep 17 00:00:00 2001 From: Oliver Date: Wed, 24 May 2023 00:38:00 +1000 Subject: [PATCH] Sales order fix backport (#4879) * Bump version to 0.11.2 * Fix for sales order tables (#4753) - Allow line items to be allocated after partial shipment - Fixes https://github.com/inventree/InvenTree/issues/4734 --- InvenTree/templates/js/translated/sales_order.js | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/InvenTree/templates/js/translated/sales_order.js b/InvenTree/templates/js/translated/sales_order.js index 29834f6caf..06533bf21b 100644 --- a/InvenTree/templates/js/translated/sales_order.js +++ b/InvenTree/templates/js/translated/sales_order.js @@ -1056,9 +1056,8 @@ function allocateStockToSalesOrder(order_id, line_items, options={}) { var table_entries = ''; for (var idx = 0; idx < line_items.length; idx++ ) { - var line_item = line_items[idx]; - - var remaining = 0; + let line_item = line_items[idx]; + let remaining = Math.max(0, line_item.quantity - line_item.allocated); table_entries += renderLineItemRow(line_item, remaining); } @@ -1225,7 +1224,7 @@ function allocateStockToSalesOrder(order_id, line_items, options={}) { var available = Math.max((data.quantity || 0) - (data.allocated || 0), 0); // Remaining quantity to be allocated? - var remaining = Math.max(line_item.quantity - line_item.shipped - line_item.allocated, 0); + var remaining = Math.max(line_item.quantity - line_item.allocated, 0); // Maximum amount that we need var desired = Math.min(available, remaining); @@ -1892,7 +1891,7 @@ function loadSalesOrderLineItemTable(table, options={}) { if (row.part && row.part_detail) { let part = row.part_detail; - if (options.allow_edit && !row.shipped) { + if (options.allow_edit && (row.shipped < row.quantity)) { if (part.trackable) { buttons += makeIconButton('fa-hashtag icon-green', 'button-add-by-sn', pk, '{% trans "Allocate serial numbers" %}'); }