mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Catch a 500 and make it a 400
While we are at it, convert __all__ to non_field_errors automatically
This commit is contained in:
parent
ae50546ca6
commit
6512c0061e
@ -77,4 +77,9 @@ def exception_handler(exc, context):
|
|||||||
# For an error response, include status code information
|
# For an error response, include status code information
|
||||||
response.data['status_code'] = response.status_code
|
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
|
return response
|
||||||
|
@ -1287,13 +1287,17 @@ class SalesOrderShipmentAllocationSerializer(serializers.Serializer):
|
|||||||
|
|
||||||
with transaction.atomic():
|
with transaction.atomic():
|
||||||
for entry in items:
|
for entry in items:
|
||||||
|
|
||||||
# Create a new SalesOrderAllocation
|
# Create a new SalesOrderAllocation
|
||||||
order.models.SalesOrderAllocation.objects.create(
|
allocation = order.models.SalesOrderAllocation(
|
||||||
line=entry.get('line_item'),
|
line=entry.get('line_item'),
|
||||||
item=entry.get('stock_item'),
|
item=entry.get('stock_item'),
|
||||||
quantity=entry.get('quantity'),
|
quantity=entry.get('quantity'),
|
||||||
shipment=shipment,
|
shipment=shipment,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
allocation.full_clean()
|
||||||
|
allocation.save()
|
||||||
|
|
||||||
|
|
||||||
class SalesOrderExtraLineSerializer(AbstractExtraLineSerializer, InvenTreeModelSerializer):
|
class SalesOrderExtraLineSerializer(AbstractExtraLineSerializer, InvenTreeModelSerializer):
|
||||||
|
Loading…
Reference in New Issue
Block a user