diff --git a/InvenTree/InvenTree/exceptions.py b/InvenTree/InvenTree/exceptions.py index f57df8ac00..78a494c9f2 100644 --- a/InvenTree/InvenTree/exceptions.py +++ b/InvenTree/InvenTree/exceptions.py @@ -77,4 +77,9 @@ def exception_handler(exc, context): # For an error response, include status code information response.data['status_code'] = response.status_code + # Convert errors returned under the label '__all__' to 'non_field_errors' + if '__all__' in response.data: + response.data['non_field_errors'] = response.data['all'] + del response.data['__all__'] + return response diff --git a/InvenTree/order/serializers.py b/InvenTree/order/serializers.py index c97090e4f6..1c261e7a86 100644 --- a/InvenTree/order/serializers.py +++ b/InvenTree/order/serializers.py @@ -1287,13 +1287,17 @@ class SalesOrderShipmentAllocationSerializer(serializers.Serializer): with transaction.atomic(): for entry in items: + # Create a new SalesOrderAllocation - order.models.SalesOrderAllocation.objects.create( + allocation = order.models.SalesOrderAllocation( line=entry.get('line_item'), item=entry.get('stock_item'), quantity=entry.get('quantity'), shipment=shipment, ) + + allocation.full_clean() + allocation.save() class SalesOrderExtraLineSerializer(AbstractExtraLineSerializer, InvenTreeModelSerializer):