From b9473c09c65efd4c1e941333cd8b5d23f00a5123 Mon Sep 17 00:00:00 2001 From: Nicolas Martinelli Date: Tue, 18 Sep 2018 13:55:04 +0200 Subject: [PATCH] [FIX] account, sale: Intrastat delivery address Forward-port of fix 034e1d37d9af08e11b3b36a31b436f7823ca737a Since there is not link module between `sale` and `account_intrastat`, we use a common method in `account.invoice`. opw-1878590 --- addons/account/models/account_invoice.py | 2 ++ addons/sale/models/account_invoice.py | 5 +++++ 2 files changed, 7 insertions(+) diff --git a/addons/account/models/account_invoice.py b/addons/account/models/account_invoice.py index c739bdf18d4..8241811e1ca 100644 --- a/addons/account/models/account_invoice.py +++ b/addons/account/models/account_invoice.py @@ -1525,6 +1525,8 @@ class AccountInvoice(models.Model): 'url': self.get_portal_url(), } + def _get_intrastat_country_id(self): + return self.partner_id.country_id.id class AccountInvoiceLine(models.Model): _name = "account.invoice.line" diff --git a/addons/sale/models/account_invoice.py b/addons/sale/models/account_invoice.py index 295f53db3a5..bcbd21350fc 100644 --- a/addons/sale/models/account_invoice.py +++ b/addons/sale/models/account_invoice.py @@ -81,6 +81,11 @@ class AccountInvoice(models.Model): def _get_refund_common_fields(self): return super(AccountInvoice, self)._get_refund_common_fields() + ['team_id', 'partner_shipping_id'] + def _get_intrastat_country_id(self): + if self.type in ['out_invoice', 'out_refund']: + return self.partner_shipping_id.country_id.id or super(AccountInvoice, self)._get_intrastat_country_id() + return super(AccountInvoice, self)._get_intrastat_country_id() + class AccountInvoiceLine(models.Model): _inherit = 'account.invoice.line'