[MERGE] base_vat: support for Norwegian VAT codes, courtesy of Rolv Råen (adEgo)

bzr revid: odo@openerp.com-20110915101130-51jabei9e5tspj6r
This commit is contained in:
Olivier Dony
2011-09-15 12:11:30 +02:00
+28 -2
View File
@@ -42,7 +42,7 @@ _ref_vat = {
'pt': 'PT123456789', 'ro': 'RO1234567897',
'se': 'SE123456789701', 'si': 'SI12345679',
'sk': 'SK0012345675', 'el': 'EL12345670',
'mx': 'MXABCD831230T1B',
'mx': 'MXABC123456T1B', 'no': 'NO123456785'
}
@@ -1104,7 +1104,33 @@ class res_partner(osv.osv):
#Valid format and valid date
return True
# check_vat_no contributed by Rolv Råen (adEgo)
def check_vat_no(self, vat):
'''
Check Norway VAT number.See http://www.brreg.no/english/coordination/number.html
'''
if len(vat) != 9:
return False
try:
int(vat)
except ValueError:
return False
sum = (3 * int(vat[0])) + (2 * int(vat[1])) + \
(7 * int(vat[2])) + (6 * int(vat[3])) + \
(5 * int(vat[4])) + (4 * int(vat[5])) + \
(3 * int(vat[6])) + (2 * int(vat[7]))
check = 11 -(sum % 11)
if check == 11:
check = 0
if check == 10:
# 10 is not a valid check digit for an organization number
return False
return check == int(vat[8])
res_partner()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: