[FIX] l10n_it_edi: fix support of customers from San Marino
Steps to reproduce: - Install Accounting, l10n_it_edi and Contacts - Switch to an Italian company (e.g. IT Company) - Go to Contacts and create a contact from San Marino: * Name: SM customer * Country: San Marino * Street, City, ZIP: [any] * Destination Code: [any] - Create an invoice: * Customer: [the created contact from San Marino] * Product: [any] - Confirm the invoice - Generate E-invoice XML via "Send & Print" button Issue: In the XML, the destination code (i.e. CodiceDestinatario) is the default one for non-Italian customer (i.e. XXXXXXX). Also, the VAT number (i.e. IdFiscaleIVA) is the default value for countries that are not in the European Union (i.e. OO99999999999). However, since October 2021, San Marino should be handled differently for Italian electronic invoices. A specific destination code (i.e. 2R4GTO8) should be used for all customers from San Marino. Source: https://www.credemtel.it/fattura-elettronica/fattura-elettronica-san-marino/ Solution: For customers from San Marino: - Keep VAT number - Set "2R4GTO8" as destination code opw-3819054 closes odoo/odoo#160494 Signed-off-by: Quentin De Paoli <qdp@odoo.com>
This commit is contained in:
@@ -69,6 +69,7 @@ class ResPartner(models.Model):
|
||||
|
||||
europe = self.env.ref('base.europe', raise_if_not_found=False)
|
||||
in_eu = not europe or not self.country_id or self.country_id in europe.country_ids
|
||||
is_sm = self.country_id and self.country_id.code == "SM"
|
||||
|
||||
# VAT number and country code
|
||||
normalized_vat = self.vat
|
||||
@@ -83,7 +84,10 @@ class ResPartner(models.Model):
|
||||
else:
|
||||
normalized_country = normalized_vat[:2].upper()
|
||||
normalized_vat = normalized_vat[2:]
|
||||
|
||||
# If customer is from San Marino
|
||||
elif is_sm:
|
||||
normalized_country = 'SM'
|
||||
normalized_vat = normalized_vat if normalized_vat[:2].isdecimal() else normalized_vat[2:]
|
||||
# The Tax Agency arbitrarily decided that non-EU VAT are not interesting,
|
||||
# so this default code is used instead
|
||||
# Detect the country code from the partner country instead
|
||||
@@ -106,7 +110,10 @@ class ResPartner(models.Model):
|
||||
zipcode = self.zip
|
||||
state_code = self.state_id and self.state_id.code
|
||||
else:
|
||||
pa_index = 'XXXXXXX'
|
||||
# San Marino is externally integrated with the SdI.
|
||||
# The country as a whole has a single fixed Destination Code.
|
||||
# https://www.agenziaentrate.gov.it/portale/documents/20143/3788702/Modifiche+ProvvedimentonSanMarino+0248717-2021.pdf/429b5571-17b9-0cce-7f62-f79cf53086d7
|
||||
pa_index = '2R4GTO8' if is_sm else 'XXXXXXX'
|
||||
zipcode = '00000'
|
||||
state_code = False
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
<DatiAnagrafici>
|
||||
<IdFiscaleIVA>
|
||||
<IdPaese>SM</IdPaese>
|
||||
<IdCodice>OO99999999999</IdCodice>
|
||||
<IdCodice>6784</IdCodice>
|
||||
</IdFiscaleIVA>
|
||||
<Anagrafica>
|
||||
<Denominazione>Prospectra</Denominazione>
|
||||
|
||||
Reference in New Issue
Block a user