diff --git a/InvenTree/order/models.py b/InvenTree/order/models.py index 05eabe3788..89585e218f 100644 --- a/InvenTree/order/models.py +++ b/InvenTree/order/models.py @@ -913,7 +913,6 @@ class SalesOrderShipment(models.Model): Attributes: order: SalesOrder reference - status: Status of this shipment (see SalesOrderStatus) shipment_date: Date this shipment was "shipped" (or null) checked_by: User reference field indicating who checked this order reference: Custom reference text for this shipment (e.g. consignment number?) diff --git a/InvenTree/order/templates/order/sales_order_detail.html b/InvenTree/order/templates/order/sales_order_detail.html index 87b6d80acf..a70f932466 100644 --- a/InvenTree/order/templates/order/sales_order_detail.html +++ b/InvenTree/order/templates/order/sales_order_detail.html @@ -113,6 +113,16 @@ order: {{ order.pk }}, shipped: false, }); + + $('#new-shipment').click(function() { + createSalesOrderShipment({ + order: {{ order.pk }}, + onSuccess: function(data) { + $('#pending-shipments-table').bootstrapTable('refresh'); + } + }); + }); + {% endif %} loadSalesOrderShipmentTable('#completed-shipments-table', { diff --git a/InvenTree/templates/js/translated/order.js b/InvenTree/templates/js/translated/order.js index 9d6db122cc..1d53824c7f 100644 --- a/InvenTree/templates/js/translated/order.js +++ b/InvenTree/templates/js/translated/order.js @@ -35,6 +35,38 @@ removePurchaseOrderLineItem, */ + +function salesOrderShipmentFields(options={}) { + var fields = { + order: {}, + reference: {}, + }; + + // If order is specified, hide the order field + if (options.order) { + fields.order.value = options.order; + fields.order.hidden = true; + } + + return fields; +} + + +// Open a dialog to create a new sales order shipment +function createSalesOrderShipment(options={}) { + constructForm('{% url "api-so-shipment-list" %}', { + method: 'POST', + fields: salesOrderShipmentFields(options), + title: '{% trans "Create New Shipment" %}', + onSuccess: function(data) { + if (options.onSuccess) { + options.onSuccess(data); + } + } + }); +} + + // Create a new SalesOrder function createSalesOrder(options={}) { @@ -1351,6 +1383,14 @@ function allocateStockToSalesOrder(order_id, line_items, options={}) { }, value: options.shipment || null, auto_fill: true, + secondary: { + title: '{% trans "New Shipment" %}', + fields: function() { + return salesOrderShipmentFields({ + order: order_id + }); + } + } } }, preFormContent: html,