From 970f40f3be722c0147a8c3c028c9dde0dbdbbbdc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Thu, 11 Jan 2024 17:09:50 +0100 Subject: [PATCH] Use internal shipment location to compute warehouse of transit stock move When the location is the transit location, the warehouse to be used is the warehouse of the corresponding location on the internal shipment. Closes #12746 --- modules/stock/move.py | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/modules/stock/move.py b/modules/stock/move.py index 52b125a84d..1a43575b72 100644 --- a/modules/stock/move.py +++ b/modules/stock/move.py @@ -683,11 +683,27 @@ class Move(Workflow, ModelSQL, ModelView): @property def from_warehouse(self): - return self.from_location.warehouse + pool = Pool() + ShipmentInternal = pool.get('stock.shipment.internal') + warehouse = self.from_location.warehouse + if (not warehouse + and isinstance(self.shipment, ShipmentInternal) + and self.from_location == getattr( + self.shipment, 'transit_location', None)): + warehouse = self.shipment.from_location.warehouse + return warehouse @property def to_warehouse(self): - return self.to_location.warehouse + pool = Pool() + ShipmentInternal = pool.get('stock.shipment.internal') + warehouse = self.to_location.warehouse + if (not warehouse + and isinstance(self.shipment, ShipmentInternal) + and self.to_location == getattr( + self.shipment, 'transit_location', None)): + warehouse = self.shipment.to_location.warehouse + return warehouse @property def warehouse(self):