Odoo Mindscape. Understand Odoo faster. Explore modules, fields, dependencies and version differences in one place instead of digging through the source code.

Module: VAT Number Validation

Entity: res.partner

Compute Method: _compute_vies_vat_to_check

Inputs Method Outputs
  • vat
  • country_id
  • country_id.code
  • country_id.id
""" Retrieve the VAT number, if one such exists, to be used when checking against the VIES system """
eu_country_codes = self.env.ref('base.europe').country_ids.mapped('code')
for partner in self:
            # Skip checks when only one character is used. Some users like to put '/' or other as VAT to differentiate between
            # a partner for which they haven't yet input VAT, and one not subject to VAT
            if not partner.vat or len(partner.vat) == 1:
                partner.vies_vat_to_check = ''
                continue
            vat_prefix, number = partner._split_vat(partner.vat)
            if not vat_prefix.isalpha() and partner.country_id:
                vat_prefix = _eu_country_vat.get(partner.country_id.code, partner.country_id.code)
                number = partner.vat
            country_code = vat_prefix.upper()
            country_code = _eu_country_vat_inverse.get(country_code, country_code)
            partner.vies_vat_to_check = (
                country_code in eu_country_codes or
                country_code.lower() in _region_specific_vat_codes
            ) and self._fix_vat_number(vat_prefix + number, partner.country_id.id) or ''

Back to entity