[FIX] l10n_it_edi: Non EU VAT fix

Non EU vendor bills are sent to the Tax Agency as self-invoices,
so the partner actually is the seller, but the same checks on the
VAT must apply as it was the buyer.

Task: https://www.odoo.com/web#id=3010849&model=project.task
opw-3010849

closes odoo/odoo#106312

X-original-commit: 8c18b870ecc04314380fcdb6b61179de78e28703
Signed-off-by: Josse Colpaert <jco@odoo.com>
Signed-off-by: Paolo Gatti (pgi) <pgi@odoo.com>
This commit is contained in:
Paolo Gatti
2022-11-23 13:24:54 +01:00
parent 29ca002ee5
commit 459684e2a1
2 changed files with 11 additions and 3 deletions
@@ -58,10 +58,18 @@
</DatiTrasmissione>
<CedentePrestatore>
<DatiAnagrafici>
<IdFiscaleIVA>
<IdFiscaleIVA t-if="seller.vat and in_eu(seller)">
<IdPaese t-out="get_vat_country(seller.vat)"/>
<IdCodice t-out="get_vat_number(seller.vat)"/>
</IdFiscaleIVA>
<IdFiscaleIVA t-if="seller.vat and not in_eu(seller)">
<IdPaese t-out="seller.country_id.code"/>
<IdCodice t-out="'OO99999999999'"/>
</IdFiscaleIVA>
<IdFiscaleIVA t-if="not seller.vat and seller.country_id.code != 'IT'">
<IdPaese t-out="seller.country_id.code"/>
<IdCodice t-out="'0000000'"/>
</IdFiscaleIVA>
<CodiceFiscale t-if="seller.l10n_it_codice_fiscale" t-out="normalize_codice_fiscale(seller.l10n_it_codice_fiscale)"/>
<Anagrafica>
<Denominazione t-out="format_alphanumeric(seller_partner.display_name[:80])"/>
@@ -96,9 +96,9 @@ class AccountEdiFormat(models.Model):
errors.append(_("%s must have a country", seller.display_name))
# <1.1.1.2>
if not seller.vat:
if not invoice.company_id.vat:
errors.append(_("%s must have a VAT number", seller.display_name))
elif len(seller.vat) > 30:
if seller.vat and len(seller.vat) > 30:
errors.append(_("The maximum length for VAT number is 30. %s have a VAT number too long: %s.", seller.display_name, seller.vat))
# <1.2.1.2>