From d58d34af25e774dd42a2469a833acf58d483e71e Mon Sep 17 00:00:00 2001 From: Oliver Date: Fri, 18 Oct 2024 10:25:55 +1100 Subject: [PATCH] [CUI] Shipment fixes (#8309) * Fix warning in "complete shipment" dialog - Broken due to recent API change / refactor * Request item detail for sub-table * Fix "ship items" button --- .../templates/js/translated/sales_order.js | 58 +++---------------- 1 file changed, 9 insertions(+), 49 deletions(-) diff --git a/src/backend/InvenTree/templates/js/translated/sales_order.js b/src/backend/InvenTree/templates/js/translated/sales_order.js index 01611aec6c..395789d400 100644 --- a/src/backend/InvenTree/templates/js/translated/sales_order.js +++ b/src/backend/InvenTree/templates/js/translated/sales_order.js @@ -281,55 +281,13 @@ function completeSalesOrderShipment(shipment_id, options={}) { // Request the list of stock items which will be shipped inventreeGet(`{% url "api-so-shipment-list" %}${shipment_id}/`, {}, { success: function(shipment) { - var allocations = shipment.allocations; + let allocations = shipment.allocated_items ?? 0; - var html = ''; - - if (!allocations || allocations.length == 0) { - html = ` -
- {% trans "No stock items have been allocated to this shipment" %} -
- `; - } else { - html = ` - {% trans "The following stock items will be shipped" %} - - - - - - - - - `; - - allocations.forEach(function(allocation) { - - var part = allocation.part_detail; - var thumb = thumbnailImage(part.thumbnail || part.image); - - var stock = ''; - - if (allocation.serial) { - stock = `{% trans "Serial Number" %}: ${allocation.serial}`; - } else { - stock = `{% trans "Quantity" %}: ${allocation.quantity}`; - } - - html += ` - - - - - `; - }); - - html += ` - -
{% trans "Part" %}{% trans "Stock Item" %}
${thumb} ${part.full_name}${stock}
- `; - } + var html = allocations == 0 ? ( + `
+ {% trans "No stock items have been allocated to this shipment" %} +
` + ) : ''; constructForm(`{% url "api-so-shipment-list" %}${shipment_id}/ship/`, { method: 'POST', @@ -398,7 +356,8 @@ function completePendingShipments(order_id, options={}) { var allocated_shipments = []; for (var idx = 0; idx < pending_shipments.length; idx++) { - if (pending_shipments[idx].allocations.length > 0) { + + if (pending_shipments[idx].allocated_items > 0) { allocated_shipments.push(pending_shipments[idx]); } } @@ -1638,6 +1597,7 @@ function showAllocationSubTable(index, row, element, options) { ...options.queryParams, part_detail: true, location_detail: true, + item_detail: true, order_detail: true, }, data: row.allocations,