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
(grafted from f4f85f4d31f0afe83bb8662d1c15ceecadbd753e)

--HG--
branch : 6.0
This commit is contained in:
Cédric Krier
2024-04-13 13:52:43 +02:00
parent bc7a3cc07c
commit c9183d7e61
+2 -1
View File
@@ -59,7 +59,8 @@ class Move(metaclass=PoolMeta):
def set_product_location(self, field='to_location', **pattern):
assert field in {'from_location', 'to_location'}
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)