From 94c1ed882fdd934a92db633f3d9ec6ace522d160 Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Sat, 7 Aug 2021 23:42:42 +1000 Subject: [PATCH] Add secondary field options for "Create Supplier Part" form - Supplier - Manufacturer Part --- InvenTree/templates/js/translated/company.js | 29 +++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/InvenTree/templates/js/translated/company.js b/InvenTree/templates/js/translated/company.js index f671fb616f..2124f5f344 100644 --- a/InvenTree/templates/js/translated/company.js +++ b/InvenTree/templates/js/translated/company.js @@ -72,7 +72,7 @@ function supplierPartFields() { filters: { part_detail: true, manufacturer_detail: true, - } + }, }, description: {}, link: { @@ -108,6 +108,33 @@ function createSupplierPart(options={}) { fields.manufacturer_part.value = options.manufacturer_part; } + // Add a secondary modal for the supplier + fields.supplier.secondary = { + title: '{% trans "Add Supplier" %}', + fields: function(data) { + var company_fields = companyFormFields(); + + company_fields.is_supplier.value = true; + + return company_fields; + } + }; + + // Add a secondary modal for the manufacturer part + fields.manufacturer_part.secondary = { + title: '{% trans "Add Manufacturer Part" %}', + fields: function(data) { + var mp_fields = manufacturerPartFields(); + + if (data.part) { + mp_fields.part.value = data.part; + mp_fields.part.hidden = true; + } + + return mp_fields; + } + }; + constructForm('{% url "api-supplier-part-list" %}', { fields: fields, method: 'POST',