From 3b28085a3f6c472a2d5b0454afc96875f152034d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADctor=20Mart=C3=ADnez?= Date: Tue, 27 Dec 2022 10:09:52 +0100 Subject: [PATCH] [FIX] intrastat_product: Set the correct country code when the country of the delivery address is different (and to be consistent with the src_dest_country_id field). (#202) TT40764 --- intrastat_product/models/intrastat_product_declaration.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/intrastat_product/models/intrastat_product_declaration.py b/intrastat_product/models/intrastat_product_declaration.py index 28839f4..72bedc3 100644 --- a/intrastat_product/models/intrastat_product_declaration.py +++ b/intrastat_product/models/intrastat_product_declaration.py @@ -586,6 +586,7 @@ class IntrastatProductDeclaration(models.Model): domain = self._prepare_invoice_domain() order = "journal_id, name" invoices = self.env["account.move"].search(domain, order=order) + partner_model = self.env["res.partner"] for invoice in invoices: @@ -632,8 +633,8 @@ class IntrastatProductDeclaration(models.Model): or partner_country == self.company_id.country_id ): continue - partner_country_code = ( - invoice.commercial_partner_id._get_intrastat_country_code() + partner_country_code = partner_model._get_intrastat_country_code( + country=partner_country, state=invoice.partner_shipping_id.state_id ) if inv_intrastat_line: