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
This commit is contained in:
Cédric Krier
2024-01-11 17:09:50 +01:00
parent ee89b4cfac
commit 970f40f3be
+18 -2
View File
@@ -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):