mirror of
https://github.com/inventree/InvenTree.git
synced 2026-10-04 09:25:21 +00:00
Improve null checks for SalesOrder.shipment (#8469)
This commit is contained in:
1 parent
e6a422f38c
commit
9ab532a067
1 file changed
+3
-3
@@ -1720,7 +1720,7 @@ class SalesOrderSerialAllocationSerializer(serializers.Serializer):
|
||||
|
||||
line_item = data['line_item']
|
||||
stock_items = data['stock_items']
|
||||
shipment = data['shipment']
|
||||
shipment = data.get('shipment', None)
|
||||
|
||||
allocations = []
|
||||
|
||||
@@ -1758,10 +1758,10 @@ class SalesOrderShipmentAllocationSerializer(serializers.Serializer):
|
||||
"""Run validation against the provided shipment instance."""
|
||||
order = self.context['order']
|
||||
|
||||
if shipment.shipment_date is not None:
|
||||
if shipment and shipment.shipment_date is not None:
|
||||
raise ValidationError(_('Shipment has already been shipped'))
|
||||
|
||||
if shipment.order != order:
|
||||
if shipment and shipment.order != order:
|
||||
raise ValidationError(_('Shipment is not associated with this order'))
|
||||
|
||||
return shipment
|
||||
|
||||
Reference in new issue
Block a user