changeset 4311509d474f in modules/stock:5.0
details: https://hg.tryton.org/modules/stock?cmd=changeset&node=4311509d474f
description:
        Set effective date of outgoing moves to effective start date

        The outgoing moves of an internal shipment with transit must use the 
effective
        start date when done.

        issue11337
        review397651002
        (grafted from 8536360509ed74b63390ff550684510c2367ead7)
diffstat:

 move.py                                    |  7 ++++++-
 tests/scenario_stock_shipment_internal.rst |  5 +++++
 2 files changed, 11 insertions(+), 1 deletions(-)

diffs (39 lines):

diff -r 5b7e3145c81d -r 4311509d474f move.py
--- a/move.py   Wed Feb 16 23:49:22 2022 +0100
+++ b/move.py   Sun Apr 03 23:54:13 2022 +0200
@@ -543,8 +543,13 @@
     def set_effective_date(self):
         pool = Pool()
         Date = pool.get('ir.date')
+        ShipmentInternal = pool.get('stock.shipment.internal')
 
-        if not self.effective_date and self.shipment:
+        if (not self.effective_date
+                and isinstance(self.shipment, ShipmentInternal)
+                and self.to_location == self.shipment.transit_location):
+            self.effective_date = self.shipment.effective_start_date
+        elif not self.effective_date and self.shipment:
             self.effective_date = self.shipment.effective_date
         if not self.effective_date:
             self.effective_date = Date.today()
diff -r 5b7e3145c81d -r 4311509d474f tests/scenario_stock_shipment_internal.rst
--- a/tests/scenario_stock_shipment_internal.rst        Wed Feb 16 23:49:22 
2022 +0100
+++ b/tests/scenario_stock_shipment_internal.rst        Sun Apr 03 23:54:13 
2022 +0200
@@ -175,12 +175,17 @@
 
     >>> shipment.click('assign_try')
     True
+    >>> shipment.effective_start_date = yesterday
     >>> shipment.click('ship')
     >>> shipment.outgoing_moves[0].state
     'done'
+    >>> shipment.outgoing_moves[0].effective_date == yesterday
+    True
     >>> shipment.click('done')
     >>> shipment.incoming_moves[0].state
     'done'
+    >>> shipment.incoming_moves[0].effective_date == today
+    True
 
 Duplicate Internal Shipment::
 

Reply via email to