[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) <nim@odoo.com>
This commit is contained in:
@@ -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>
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user