From e6727f228675d04a65f3f6995f2d19282d32dad6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Phil=C3=A9mon=20van=20Helden?= Date: Tue, 15 Jun 2021 07:04:43 +0000 Subject: [PATCH] [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) Signed-off-by: pvh-odoo --- addons/base_vat/models/res_partner.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/addons/base_vat/models/res_partner.py b/addons/base_vat/models/res_partner.py index 936ba3596ae..af0f09ac077 100644 --- a/addons/base_vat/models/res_partner.py +++ b/addons/base_vat/models/res_partner.py @@ -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)