Use the intrastat country of production warehouse for production location

Closes #13524
This commit is contained in:
Cédric Krier
2024-09-18 10:59:32 +02:00
parent e8b8d6758a
commit 1e85b264ca
5 changed files with 31 additions and 1 deletions
+4
View File
@@ -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,
+1
View File
@@ -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'),
+24
View File
@@ -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'
@@ -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
+1
View File
@@ -16,6 +16,7 @@ extras_depend:
carrier
carrier_carriage
incoterm
production
purchase
sale
sale_supply_drop_shipment