[FIX] base_vat: validation for Chile and Colombia

Add validation using stdnum library since vatnumber is deprecated.

closes odoo/odoo#35433

Signed-off-by: Nicolas Martinelli (nim) <nim@odoo.com>
This commit is contained in:
Jigar Vaghela
2019-08-07 06:19:35 +00:00
committed by Nicolas Martinelli
parent 48b3893b84
commit 066722b2f6
+15
View File
@@ -14,6 +14,13 @@ except ImportError:
"Install it to support more countries, for example with `easy_install vatnumber`.")
vatnumber = None
# Although stdnum is a dependency of vatnumber, the import of the latter is surrounded by a try/except
# if it is not installed. Therefore, we cannot be sure stdnum is installed in all cases.
try:
import stdnum
except ImportError:
stdnum = None
from odoo import api, models, _
from odoo.tools.misc import ustr
from odoo.exceptions import ValidationError
@@ -29,6 +36,8 @@ _ref_vat = {
'be': 'BE0477472701',
'bg': 'BG1234567892',
'ch': 'CHE-123.456.788 TVA or CH TVA 123456', # Swiss by Yannick Vaucher @ Camptocamp
'cl': 'CL76086428-5',
'co': 'CO213123432-1 or CO213.123.432-1',
'cy': 'CY12345678F',
'cz': 'CZ12345679',
'de': 'DE123456788',
@@ -363,3 +372,9 @@ class ResPartner(models.Model):
return stdnum.al.vat.is_valid(vat)
except ImportError:
return True
def check_vat_cl(self, vat):
return stdnum.util.get_cc_module('cl', 'vat').is_valid(vat) if stdnum else True
def check_vat_co(self, vat):
return stdnum.util.get_cc_module('co', 'vat').is_valid(vat) if stdnum else True