Skip to content

Commit

Permalink
Improve null checks for SalesOrder.shipment (#8469)
Browse files Browse the repository at this point in the history
  • Loading branch information
SchrodingersGat authored Nov 12, 2024
1 parent e6a422f commit 9ab532a
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/backend/InvenTree/order/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -1720,7 +1720,7 @@ def save(self):

line_item = data['line_item']
stock_items = data['stock_items']
shipment = data['shipment']
shipment = data.get('shipment', None)

allocations = []

Expand Down Expand Up @@ -1758,10 +1758,10 @@ def validate_shipment(self, shipment):
"""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
Expand Down

0 comments on commit 9ab532a

Please sign in to comment.