diff --git a/InvenTree/order/templates/order/order_base.html b/InvenTree/order/templates/order/order_base.html index 0d46207c33..e0228ac949 100644 --- a/InvenTree/order/templates/order/order_base.html +++ b/InvenTree/order/templates/order/order_base.html @@ -188,6 +188,11 @@ $("#edit-order").click(function() { }); $("#receive-order").click(function() { + + receivePurchaseOrder({{ order.pk }}); + + return; + launchModalForm("{% url 'po-receive' order.id %}", { reload: true, secondary: [ diff --git a/InvenTree/templates/js/translated/order.js b/InvenTree/templates/js/translated/order.js index c6dd773373..d304b1c42b 100644 --- a/InvenTree/templates/js/translated/order.js +++ b/InvenTree/templates/js/translated/order.js @@ -103,6 +103,146 @@ function removeOrderRowFromOrderWizard(e) { $('#' + row).remove(); } + +function receivePurchaseOrder(orderId, options={}) { + /* Receive parts against a purchase order. + * Launches a modal form. + * + * Required Args: + * - orderId: pk value for the PurchaseOrder + * + * Optional Args: + * - lines: List of purchase order lines to receive + * (If omitted, lines will be requested via the API) + */ + + // List of lines to receive + var selectedLines = options.lines || []; + + // List of line items to receive + var lineItems = []; + + inventreeGet( + '{% url "api-po-line-list" %}', + { + order: orderId, + part_detail: true, + }, + { + success: function(results) { + for (var idx = 0; idx < results.length; idx++) { + var line = results[idx]; + + // Skip / ignore lines missing part information + if (!line.part || !line.supplier_part_detail.part) { + continue; + } + + // Skip / ignore lines which are fully received + if (line.received >= line.quantity) { + continue; + } + + if (selectedLines.length == 0 || selectedLines.includes(line.pk)) { + lineItems.push(line); + } + } + + // Construct a form for processing + var html = ` +
{% trans "Part" %} | +{% trans "SKU" %} | +{% trans "On Order" %} | +{% trans "Received" %} | +{% trans "Quantity" %} | +{% trans "Status" %} | +{% trans "Destination" %} | ++ |
---|