diff --git a/InvenTree/templates/js/translated/model_renderers.js b/InvenTree/templates/js/translated/model_renderers.js index 3136ebee29..0c3dabc27e 100644 --- a/InvenTree/templates/js/translated/model_renderers.js +++ b/InvenTree/templates/js/translated/model_renderers.js @@ -112,7 +112,13 @@ function renderStockLocation(name, data, parameters, options) { var html = `${level}${data.pathstring}`; - if (data.description) { + var render_description = true; + + if ('render_description' in parameters) { + render_description = parameters['render_description']; + } + + if (render_description && data.description) { html += ` - ${data.description}`; } diff --git a/InvenTree/templates/js/translated/order.js b/InvenTree/templates/js/translated/order.js index 613499344c..ff41ca610a 100644 --- a/InvenTree/templates/js/translated/order.js +++ b/InvenTree/templates/js/translated/order.js @@ -249,6 +249,14 @@ function newPurchaseOrderFromOrderWizard(e) { */ function receivePurchaseOrderItems(order_id, line_items, options={}) { + if (line_items.length == 0) { + showAlertDialog( + '{% trans "Select Line Items" %}', + '{% trans "At least one line item must be selected" %}', + ); + return; + } + function renderLineItem(line_item, opts={}) { var pk = line_item.pk; @@ -343,9 +351,9 @@ function receivePurchaseOrderItems(order_id, line_items, options={}) { {% trans "Order Code" %} {% trans "On Order" %} {% trans "Received" %} - {% trans "Receive" %} + {% trans "Receive" %} {% trans "Status" %} - {% trans "Destination" %} + {% trans "Destination" %} @@ -365,7 +373,39 @@ function receivePurchaseOrderItems(order_id, line_items, options={}) { confirmMessage: '{% trans "Confirm receipt of items" %}', title: '{% trans "Receive Purchase Order Items" %}', afterRender: function(fields, opts) { - // TODO + // Initialize the "destination" field for each item + line_items.forEach(function(item) { + + var pk = item.pk; + + var name = `items_location_${pk}`; + + var field_details = { + name: name, + api_url: '{% url "api-location-list" %}', + filters: { + + }, + type: 'related field', + model: 'stocklocation', + required: false, + auto_fill: false, + value: item.destination, + render_description: false, + }; + + initializeRelatedField( + field_details, + null, + opts, + ); + + addClearCallback( + name, + field_details, + opts + ); + }); }, onSubmit: function(fields, opts) { // TODO