changeset db9fe1bd0c7c in modules/stock:6.2
details: https://hg.tryton.org/modules/stock?cmd=changeset&node=db9fe1bd0c7c
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 (42 lines):

diff -r ff3653a38fd7 -r db9fe1bd0c7c move.py
--- a/move.py   Sat Apr 02 00:01:46 2022 +0200
+++ b/move.py   Sun Apr 03 23:54:13 2022 +0200
@@ -605,8 +605,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 ff3653a38fd7 -r db9fe1bd0c7c tests/scenario_stock_shipment_internal.rst
--- a/tests/scenario_stock_shipment_internal.rst        Sat Apr 02 00:01:46 
2022 +0200
+++ b/tests/scenario_stock_shipment_internal.rst        Sun Apr 03 23:54:13 
2022 +0200
@@ -181,15 +181,20 @@
 
     >>> shipment.click('assign_try')
     True
+    >>> shipment.effective_start_date = yesterday
     >>> shipment.click('ship')
     >>> incoming_move, = shipment.incoming_moves
     >>> incoming_move.quantity
     1.0
     >>> 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