diff --git a/modules/account_stock_eu/__init__.py b/modules/account_stock_eu/__init__.py index c511154eff..3794d375cb 100644 --- a/modules/account_stock_eu/__init__.py +++ b/modules/account_stock_eu/__init__.py @@ -29,6 +29,10 @@ def register(): stock.ShipmentOutReturn, stock.ShipmentInternal, module='account_stock_eu', type_='model') + Pool.register( + stock.Move_Production, + module='account_stock_eu', type_='model', + depends=['production']) Pool.register( account_stock_eu.IntrastatDeclarationLine_Incoterm, stock.Move_Incoterm, diff --git a/modules/account_stock_eu/setup.py b/modules/account_stock_eu/setup.py index 7965bc77ac..5b5d30d72b 100755 --- a/modules/account_stock_eu/setup.py +++ b/modules/account_stock_eu/setup.py @@ -51,6 +51,7 @@ tests_require = [ get_require_version('proteus'), get_require_version('trytond_carrier'), get_require_version('trytond_incoterm'), + get_require_version('trytond_production'), get_require_version('trytond_purchase_shipment_cost'), get_require_version('trytond_stock_consignment'), get_require_version('trytond_stock_package_shipping'), diff --git a/modules/account_stock_eu/stock.py b/modules/account_stock_eu/stock.py index 11d137eebd..895045855e 100644 --- a/modules/account_stock_eu/stock.py +++ b/modules/account_stock_eu/stock.py @@ -479,6 +479,30 @@ class Move(metaclass=PoolMeta): return self.shipment.customer +class Move_Production(metaclass=PoolMeta): + __name__ = 'stock.move' + + @property + @fields.depends('from_location', 'production') + def intrastat_from_country(self): + country = super().intrastat_from_country + if self.from_location: + if (self.from_location.type == 'production' + and self.production and self.production.warehouse.address): + country = self.production.warehouse.address.country + return country + + @property + @fields.depends('to_location', 'production') + def intrastat_to_country(self): + country = super().intrastat_to_country + if self.to_location: + if (self.to_location.type == 'production' + and self.production and self.production.warehouse.address): + country = self.production.warehouse.address.country + return country + + class Move_Incoterm(metaclass=PoolMeta): __name__ = 'stock.move' diff --git a/modules/account_stock_eu/tests/test_module.py b/modules/account_stock_eu/tests/test_module.py index 7e0facc970..20b9469199 100644 --- a/modules/account_stock_eu/tests/test_module.py +++ b/modules/account_stock_eu/tests/test_module.py @@ -6,7 +6,7 @@ from trytond.tests.test_tryton import ModuleTestCase class AccountStockEuTestCase(ModuleTestCase): "Test Account Stock Eu module" module = 'account_stock_eu' - extras = ['carrier', 'incoterm', 'stock_consignment'] + extras = ['carrier', 'incoterm', 'production', 'stock_consignment'] del ModuleTestCase diff --git a/modules/account_stock_eu/tryton.cfg b/modules/account_stock_eu/tryton.cfg index 467419d021..b4b9b1eed1 100644 --- a/modules/account_stock_eu/tryton.cfg +++ b/modules/account_stock_eu/tryton.cfg @@ -16,6 +16,7 @@ extras_depend: carrier carrier_carriage incoterm + production purchase sale sale_supply_drop_shipment