[FIX] base_vat: properly checks NL VAT numbers
In 12.0+ when adding an NL VAT number on a contact without specifying the country as Netherlands, an error shows the VAT number as not valid. This is because the method to check specifically NL VAT numbers requires the complete VAT number with country code, when the country code isn't always provided. With this commit, we allow the check_vat_nl method to take the NL VAT number as argument, with or without the country code. opw-2536261 closes odoo/odoo#72382 X-original-commit: 75cfe3f484bd56723b182def09141d929a3169a1 Signed-off-by: Nicolas Lempereur (nle) <nle@odoo.com> Signed-off-by: pvh-odoo <SwagSamaSempai@users.noreply.github.com>
This commit is contained in:
@@ -333,7 +333,11 @@ class ResPartner(models.Model):
|
||||
|
||||
vat = clean(vat, ' -.').upper().strip()
|
||||
|
||||
if not (len(vat) == 14):
|
||||
# Remove the prefix
|
||||
if vat.startswith("NL"):
|
||||
vat = vat[2:]
|
||||
|
||||
if not len(vat) == 12:
|
||||
return False
|
||||
|
||||
# Check the format
|
||||
@@ -346,9 +350,6 @@ class ResPartner(models.Model):
|
||||
char_to_int['+'] = '36'
|
||||
char_to_int['*'] = '37'
|
||||
|
||||
# Remove the prefix
|
||||
vat = vat[2:]
|
||||
|
||||
# 2 possible checks:
|
||||
# - For natural persons
|
||||
# - For non-natural persons and combinations of natural persons (company)
|
||||
|
||||
Reference in New Issue
Block a user