Skip to content

Commit

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

- Ref: #6449

* Update unit test

(cherry picked from commit db128f9)

Co-authored-by: Oliver <[email protected]>
  • Loading branch information
github-actions[bot] and SchrodingersGat authored Nov 28, 2024
1 parent a4894d9 commit d0b87a1
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 @@ -1098,6 +1098,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 @@ -1576,6 +1576,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 @@ -1591,9 +1593,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 @@ -1603,6 +1610,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 d0b87a1

Please sign in to comment.