From 8cd8581dbf8bdba49c765ce698b7582b7f4f4be9 Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Tue, 3 May 2022 13:51:04 +1000 Subject: [PATCH] fixes --- InvenTree/order/serializers.py | 14 ++++++++++++-- InvenTree/templates/js/translated/order.js | 8 ++++---- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/InvenTree/order/serializers.py b/InvenTree/order/serializers.py index eabc5e630e..660a278cf5 100644 --- a/InvenTree/order/serializers.py +++ b/InvenTree/order/serializers.py @@ -268,8 +268,18 @@ class PurchaseOrderLineItemSerializer(InvenTreeModelSerializer): data = super().validate(data) - supplier_part = data['part'] - purchase_order = data['order'] + supplier_part = data.get('part', None) + purchase_order = data.get('order', None) + + if not supplier_part: + raise ValidationError({ + 'part': _('Supplier part must be specified'), + }) + + if not purchase_order: + raise ValidationError({ + 'order': _('Purchase order must be specified'), + }) # Check that the supplier part and purchase order match if supplier_part is not None and supplier_part.supplier != purchase_order.supplier: diff --git a/InvenTree/templates/js/translated/order.js b/InvenTree/templates/js/translated/order.js index 042e5b785b..b17130d05b 100644 --- a/InvenTree/templates/js/translated/order.js +++ b/InvenTree/templates/js/translated/order.js @@ -534,7 +534,7 @@ function orderParts(parts_list, options={}) { `; var supplier_part_input = constructField( - `supplier_part_${pk}`, + `part_${pk}`, { type: 'related field', required: true, @@ -631,7 +631,7 @@ function orderParts(parts_list, options={}) { parts.forEach(function(part) { // Configure the "supplier part" field initializeRelatedField({ - name: `supplier_part_${part.pk}`, + name: `part_${part.pk}`, model: 'supplierpart', api_url: '{% url "api-supplier-part-list" %}', required: true, @@ -674,7 +674,7 @@ function orderParts(parts_list, options={}) { // Extract information from the row var data = { quantity: getFormFieldValue(`quantity_${pk}`, {type: 'decimal',}, opts), - supplier_part: getFormFieldValue(`supplier_part_${pk}`, {}, opts), + part: getFormFieldValue(`part_${pk}`, {}, opts), order: getFormFieldValue(`order_${pk}`, {}, opts), } @@ -725,7 +725,7 @@ function orderParts(parts_list, options={}) { part: pk, onSuccess: function(response) { setRelatedFieldData( - `supplier_part_${pk}`, + `part_${pk}`, response, opts );