2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-05-01 21:16:46 +00:00

Improve null checks for SalesOrder.shipment (#8469)

This commit is contained in:
Oliver 2024-11-12 19:55:49 +11:00 committed by GitHub
parent e6a422f38c
commit 9ab532a067
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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