check vat: handle the case of an unknow country code

bzr revid: christophe@tinyerp.com-20080826143201-vfxsg7hvkrsly83h
This commit is contained in:
Christophe Simonis 2008-08-26 16:32:01 +02:00
parent 51c6c66a7c
commit b93adda14d
2 changed files with 4 additions and 2 deletions

View File

@ -28,7 +28,7 @@
###############################################################################
{
"name" : "VAT",
"description": "Enable the VAT Number for the partner. Check the validity of that VAT Number (idea and code from Tryton (B2CK)).",
"description": "Enable the VAT Number for the partner. Check the validity of that VAT Number.",
"version" : "1.0",
"author" : "Tiny",
"category" : "Generic Modules/Base",

View File

@ -51,7 +51,9 @@ class res_partner(osv.osv):
continue #FIXME return False? empty vat numbre is invalid?
vat_country, vat_number = partner.vat[:2].lower(), partner.vat[2:]
if not getattr(self, 'check_vat_' + vat_country)(vat_number):
check = getattr(self, 'check_vat_' + vat_country, lambda vn: False)
if not check(vat_number):
return False
return True