2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-07-15 01:11:27 +00:00

[Feature] Shipment Creation in Stock Allocation Modal (#3024)

* Added order reference to line item options

* Basic working version implemented

* Re-execute fields function in secondary modals

* Added missing argument and parameter

* Added missing parentheses

* Fixed hidden field name for depth > 0
This commit is contained in:
Maksim Stojkovic
2022-05-22 09:34:38 +10:00
committed by GitHub
parent 40153b94a5
commit 0ec067da40
3 changed files with 65 additions and 5 deletions

View File

@ -2593,6 +2593,55 @@ function allocateStockToSalesOrder(order_id, line_items, options={}) {
},
value: options.shipment || null,
auto_fill: true,
secondary: {
method: 'POST',
title: '{% trans "Add Shipment" %}',
fields: function() {
var ref = null;
// TODO: Refactor code for getting next shipment number
inventreeGet(
'{% url "api-so-shipment-list" %}',
{
order: options.order,
},
{
async: false,
success: function(results) {
// "predict" the next reference number
ref = results.length + 1;
var found = false;
while (!found) {
var no_match = true;
for (var ii = 0; ii < results.length; ii++) {
if (ref.toString() == results[ii].reference.toString()) {
no_match = false;
break;
}
}
if (no_match) {
break;
} else {
ref++;
}
}
}
}
);
var fields = salesOrderShipmentFields(options);
fields.reference.value = ref;
fields.reference.prefix = global_settings.SALESORDER_REFERENCE_PREFIX + options.reference;
return fields;
}
}
}
},
preFormContent: html,
@ -3475,6 +3524,8 @@ function loadSalesOrderLineItemTable(table, options={}) {
line_item
],
{
order: options.order,
reference: options.reference,
success: function() {
// Reload this table
$(table).bootstrapTable('refresh');