Do not fail to get product location for shipment without warehouse

The warehouse of internal shipment is computed and may be empty if the from
location does not have a warehouse.

Closes #13129
This commit is contained in:
Cédric Krier
2024-04-13 13:52:43 +02:00
parent e0801df2f6
commit cf02996a09
+2 -1
View File
@@ -64,7 +64,8 @@ class Move(metaclass=PoolMeta):
def get_product_location(self, **pattern):
"Return the product location for the move"
if getattr(self, 'shipment', None):
if (getattr(self, 'shipment', None)
and getattr(self.shipment, 'warehouse', None)):
pattern.setdefault('warehouse', self.shipment.warehouse.id)
elif getattr(self, 'production', None):
pattern.setdefault('warehouse', self.production.warehouse.id)