summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolas Martinelli <nim@odoo.com>2020-10-16 09:19:02 +0000
committerNicolas Martinelli <nim@odoo.com>2020-10-21 08:49:07 +0000
commit018b594506bc15ab462911f8bdf64e4d8dcf20a8 (patch)
tree686ed1e5e5955827ef45f6e1cbe8935d37fdb98f
parent27b755a3dfe1e2a580fd436038a60df19e9d83ab (diff)
[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#60410 X-original-commit: 35267c59c32f747351e8741cfe6011749914e809 Signed-off-by: Nicolas Martinelli (nim) <nim@odoo.com>
-rw-r--r--addons/l10n_it_edi/data/invoice_it_template.xml6
-rw-r--r--addons/l10n_it_edi/models/account_invoice.py8
2 files changed, 13 insertions, 1 deletions
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 @@
</RappresentanteFiscale>
<CessionarioCommittente>
<DatiAnagrafici>
- <IdFiscaleIVA t-if="record.commercial_partner_id.vat">
+ <IdFiscaleIVA t-if="record.commercial_partner_id.vat and in_eu(record.commercial_partner_id)">
<IdPaese t-esc="get_vat_country(record.commercial_partner_id.vat)"/>
<IdCodice t-esc="get_vat_number(record.commercial_partner_id.vat)"/>
</IdFiscaleIVA>
+ <IdFiscaleIVA t-if="record.commercial_partner_id.vat and not in_eu(record.commercial_partner_id)">
+ <IdPaese t-esc="record.commercial_partner_id.country_id.code"/>
+ <IdCodice t-esc="'OO99999999999'"/>
+ </IdFiscaleIVA>
<IdFiscaleIVA t-if="not record.commercial_partner_id.vat and record.commercial_partner_id.country_id.code != 'IT'">
<IdCodice t-esc="'0000000'"/>
</IdFiscaleIVA>
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,