From 490ee8890e98b52302e5b240b1c4f2d1febf4afc Mon Sep 17 00:00:00 2001 From: Nicolas Martinelli Date: Fri, 16 Oct 2020 09:19:02 +0000 Subject: [PATCH] [FIX] l10n_it_edi: customer outside EU - Create a partner outside Europe - Set a VAT number - Create an invoice for the partner - Post the invoice The `IdPaese` and `IdCodice` is obtained from the VAT number, but it is not correct for partners outside Europe: the VAT number should always be `OO99999999999`. A workaround is to set the VAT number of the partner to `XXOO99999999999`, where `XX` is the country code. However, in case of multi-company with shared partners, another company might need the proper VAT number. In case of a customer outside EU, we: - get the `IdPaese` from the country of the partner - set the `IdCodice` to `OO99999999999` We also add the `IdPaese` to customers without VAT. opw-2355842 closes odoo/odoo#60416 X-original-commit: 35267c59c32f747351e8741cfe6011749914e809 Signed-off-by: Nicolas Martinelli (nim) --- addons/l10n_it_edi/data/invoice_it_template.xml | 6 +++++- addons/l10n_it_edi/models/account_invoice.py | 8 ++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/addons/l10n_it_edi/data/invoice_it_template.xml b/addons/l10n_it_edi/data/invoice_it_template.xml index 48f8ff7562a..df2114839ca 100644 --- a/addons/l10n_it_edi/data/invoice_it_template.xml +++ b/addons/l10n_it_edi/data/invoice_it_template.xml @@ -107,10 +107,14 @@ - + + + + + diff --git a/addons/l10n_it_edi/models/account_invoice.py b/addons/l10n_it_edi/models/account_invoice.py index b84b5f67747..9354ed80f8e 100644 --- a/addons/l10n_it_edi/models/account_invoice.py +++ b/addons/l10n_it_edi/models/account_invoice.py @@ -201,6 +201,13 @@ class AccountMove(models.Model): def get_vat_country(vat): return vat[:2].upper() + def in_eu(partner): + europe = self.env.ref('base.europe', raise_if_not_found=False) + country = partner.country_id + if not europe or not country or country in europe.country_ids: + return True + return False + formato_trasmissione = "FPR12" if len(self.commercial_partner_id.l10n_it_pa_index or '1') == 6: formato_trasmissione = "FPA12" @@ -227,6 +234,7 @@ class AccountMove(models.Model): 'discount_type': discount_type, 'get_vat_number': get_vat_number, 'get_vat_country': get_vat_country, + 'in_eu': in_eu, 'abs': abs, 'formato_trasmissione': formato_trasmissione, 'document_type': document_type,