2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-05-01 13:06:45 +00:00

Bug fix: record shipment date (#8580)

* Bug fix: record shipment date

- Ref: https://github.com/inventree/InvenTree/pull/6449

* Update unit test
This commit is contained in:
Oliver 2024-11-28 15:48:06 +11:00 committed by GitHub
parent 49cb63cb54
commit db128f9322
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 12 additions and 0 deletions

View File

@ -1176,6 +1176,8 @@ class SalesOrder(TotalPriceMixin, Order):
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()

View File

@ -1633,6 +1633,8 @@ class SalesOrderTest(OrderTest):
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"
@ -1648,9 +1650,14 @@ class SalesOrderTest(OrderTest):
# 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)
@ -1660,6 +1667,9 @@ class SalesOrderTest(OrderTest):
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."""