diff --git a/addons/account_edi_ubl_cii/i18n/account_edi_ubl_cii.pot b/addons/account_edi_ubl_cii/i18n/account_edi_ubl_cii.pot index a6531a09fdd..72c37e67ead 100644 --- a/addons/account_edi_ubl_cii/i18n/account_edi_ubl_cii.pot +++ b/addons/account_edi_ubl_cii/i18n/account_edi_ubl_cii.pot @@ -785,6 +785,13 @@ msgid "" "the form: NO179728982MVA." msgstr "" +#. module: account_edi_ubl_cii +#. odoo-python +#: code:addons/account_edi_ubl_cii/models/account_edi_xml_ubl_bis3.py:0 +#, python-format +msgid "The VAT of the %s should be prefixed with its country code." +msgstr "" + #. module: account_edi_ubl_cii #. odoo-python #: code:addons/account_edi_ubl_cii/models/account_edi_xml_cii_facturx.py:0 diff --git a/addons/account_edi_ubl_cii/models/account_edi_xml_ubl_bis3.py b/addons/account_edi_ubl_cii/models/account_edi_xml_ubl_bis3.py index 4ff48152d02..0d30c92e62b 100644 --- a/addons/account_edi_ubl_cii/models/account_edi_xml_ubl_bis3.py +++ b/addons/account_edi_ubl_cii/models/account_edi_xml_ubl_bis3.py @@ -59,10 +59,14 @@ class AccountEdiXmlUBLBIS3(models.AbstractModel): vals.pop('registration_name', None) vals.pop('registration_address_vals', None) - # /!\ For Australian companies, the ABN is encoded on the VAT field, but doesn't have the 2 digits prefix, - # causing a validation error - if partner.country_id.code == "AU" and partner.vat and not partner.vat.upper().startswith("AU"): - vals['company_id'] = "AU" + partner.vat + # Some extra european countries use Bis 3 but do not prepend their VAT with the country code (i.e. + # Australia). Allow them to use Bis 3 without raising BR-CO-09. + if ( + partner.country_id + and partner.country_id not in self.env.ref('base.europe').country_ids + and not partner.vat[:2].isalpha() + ): + vals['company_id'] = partner.country_id.code + partner.vat # sources: # https://anskaffelser.dev/postaward/g3/spec/current/billing-3.0/norway/#_applying_foretaksregisteret @@ -327,6 +331,19 @@ class AccountEdiXmlUBLBIS3(models.AbstractModel): # /!\ exception: possible to have any number of ecotaxes (fixed tax) with a regular percentage tax constraints.update({'cen_en16931_tax_line': _("Each invoice line shall have one and only one tax.")}) + for role in ('supplier', 'customer'): + scheme_vals = vals['vals'][f'accounting_{role}_party_vals']['party_vals']['party_tax_scheme_vals'][-1:] + if ( + not (scheme_vals and scheme_vals[0]['company_id'] and scheme_vals[0]['company_id'][:2].isalpha()) + and (scheme_vals and scheme_vals[0]['tax_scheme_vals'].get('id') == 'VAT') + and self._name in ('account.edi.xml.ubl_bis3', 'account.edi.xml.ubl_nl', 'account.edi.xml.ubl_de') + ): + # [BR-CO-09]-The Seller VAT identifier (BT-31), the Seller tax representative VAT identifier (BT-63) + # and the Buyer VAT identifier (BT-48) shall have a prefix in accordance with ISO code ISO 3166-1 + # alpha-2 by which the country of issue may be identified. Nevertheless, Greece may use the prefix ‘EL’. + constraints.update({f'cen_en16931_{role}_vat_country_code': _( + "The VAT of the %s should be prefixed with its country code.", role)}) + return constraints def _invoice_constraints_peppol_en16931_ubl(self, invoice, vals):