Skip to content

Commit

Permalink
Bug fix: record shipment date (#8580)
Browse files Browse the repository at this point in the history
* Bug fix: record shipment date

- Ref: #6449

* Update unit test
  • Loading branch information
SchrodingersGat authored Nov 28, 2024
1 parent 49cb63c commit db128f9
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/backend/InvenTree/order/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -1176,6 +1176,8 @@ def _action_complete(self, *args, **kwargs):
self.status = SalesOrderStatus.COMPLETE.value
else:
self.status = SalesOrderStatus.SHIPPED.value

if self.shipment_date is None:
self.shipped_by = user
self.shipment_date = InvenTree.helpers.current_date()

Expand Down
10 changes: 10 additions & 0 deletions src/backend/InvenTree/order/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -1633,6 +1633,8 @@ def test_sales_order_complete(self):

so.refresh_from_db()
self.assertEqual(so.status, SalesOrderStatus.SHIPPED.value)
self.assertIsNotNone(so.shipment_date)
self.assertIsNotNone(so.shipped_by)

# Now, let's try to "complete" the shipment again
# This time it should get marked as "COMPLETE"
Expand All @@ -1648,9 +1650,14 @@ def test_sales_order_complete(self):

# Next, we'll change the setting so that the order status jumps straight to "complete"
so.status = SalesOrderStatus.PENDING.value
so.shipment_date = None
so.shipped_by = None
so.save()
so.refresh_from_db()

self.assertEqual(so.status, SalesOrderStatus.PENDING.value)
self.assertIsNone(so.shipped_by)
self.assertIsNone(so.shipment_date)

InvenTreeSetting.set_setting('SALESORDER_SHIP_COMPLETE', True)

Expand All @@ -1660,6 +1667,9 @@ def test_sales_order_complete(self):
so.refresh_from_db()
self.assertEqual(so.status, SalesOrderStatus.COMPLETE.value)

self.assertIsNotNone(so.shipment_date)
self.assertIsNotNone(so.shipped_by)


class SalesOrderLineItemTest(OrderTest):
"""Tests for the SalesOrderLineItem API."""
Expand Down

0 comments on commit db128f9

Please sign in to comment.