Skip to content
Snippets Groups Projects
Commit c36efd42 authored by Nicolas Martinelli's avatar Nicolas Martinelli
Browse files

[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#60404

X-original-commit: 35267c59
Signed-off-by: default avatarNicolas Martinelli (nim) <nim@odoo.com>
parent 664f8f44
No related branches found
No related tags found
No related merge requests found
......@@ -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>
......
......@@ -219,6 +219,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"
......@@ -245,6 +252,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,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment