From 915395e676afe031758334767d655d8cb14ab4e0 Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Thu, 13 Jun 2019 20:35:15 +1000 Subject: [PATCH] Create a new supplier part directly from the order form --- .../order/order_wizard/select_parts.html | 2 +- InvenTree/static/script/inventree/order.js | 31 ++++++++++++++++++- 2 files changed, 31 insertions(+), 2 deletions(-) diff --git a/InvenTree/order/templates/order/order_wizard/select_parts.html b/InvenTree/order/templates/order/order_wizard/select_parts.html index 755d4812bc..f8ed6e2a93 100644 --- a/InvenTree/order/templates/order/order_wizard/select_parts.html +++ b/InvenTree/order/templates/order/order_wizard/select_parts.html @@ -37,7 +37,7 @@ diff --git a/InvenTree/static/script/inventree/order.js b/InvenTree/static/script/inventree/order.js index 09e50fa4b6..79ac2b76bd 100644 --- a/InvenTree/static/script/inventree/order.js +++ b/InvenTree/static/script/inventree/order.js @@ -8,4 +8,33 @@ function removeOrderRowFromOrderWizard(e) { var row = $(src).attr('row'); $('#' + row).remove(); -} \ No newline at end of file +} + +function newSupplierPartFromOrderWizard(e) { + /* Create a new supplier part directly from an order form. + * Launches a secondary modal and (if successful), + * back-populates the selected row. + */ + + e = e || window.event; + + var src = e.target || e.srcElement; + + var part = $(src).attr('part-id'); + + launchModalForm("/supplier-part/new/", { + modal: '#modal-form-secondary', + data: { + part: part, + }, + success: function(response) { + /* A new supplier part has been created! */ + + var dropdown = '#id_supplier_part_' + part; + + var option = new Option(response.text, response.pk, true, true); + + $('#modal-form').find(dropdown).append(option).trigger('change'); + }, + }); +}