Test if production has warehouse before reading its address

Closes #14307
This commit is contained in:
Sergi Almacellas Abellana
2025-10-21 18:24:52 +02:00
parent 342a7a42f9
commit ab7856ddcd
+6 -2
View File
@@ -486,7 +486,9 @@ class Move_Production(metaclass=PoolMeta):
country = super().intrastat_from_country
if self.from_location:
if (self.from_location.type == 'production'
and self.production and self.production.warehouse.address):
and self.production
and getattr(self.production, 'warehouse', None)
and self.production.warehouse.address):
country = self.production.warehouse.address.country
return country
@@ -496,7 +498,9 @@ class Move_Production(metaclass=PoolMeta):
country = super().intrastat_to_country
if self.to_location:
if (self.to_location.type == 'production'
and self.production and self.production.warehouse.address):
and self.production
and getattr(self.production, 'warehouse', None)
and self.production.warehouse.address):
country = self.production.warehouse.address.country
return country