Hi guys
I want to edit the following code from base_vat.py
I added Vat for Sout africa and thats all good but want to get rid of the 2 digits in front of the number
as in South africa its just a number ..
Any help to remove the whole checking is also OK
Thanks
Lawrenceimport string
from osv import osv, fields
from tools.translate import _
_ref_vat = { mport string 'be': 'BE0477472701', 'at': 'ATU12345675',
'bg': 'BG1234567892', 'cy': 'CY12345678F', from osv import osv, fields 'cz': 'CZ12345679', 'de':
'DE123456788', from tools.translate import _ 'dk': 'DK12345674', 'ee': 'EE123456780',
'es': 'ESA12345674', 'fi': 'FI12345671', _ref_vat = { 'fr': 'FR32123456789', 'gb': 'GB123456782',
'be': 'BE0477472701', 'at': 'ATU12345675', 'gr': 'GR12345670', 'hu': 'HU12345676',
'bg': 'BG1234567892', 'cy': 'CY12345678F', 'ie': 'IE1234567T', 'it': 'IT12345670017',
'cz': 'CZ12345679', 'de': 'DE123456788', 'lt': 'LT123456715', 'lu': 'LU12345613',
'dk': 'DK12345674', 'ee': 'EE123456780', 'lv': 'LV41234567891', 'mt': 'MT12345634',
'es': 'ESA12345674', 'fi': 'FI12345671', 'nl': 'NL123456782B90', 'pl': 'PL1234567883',
'fr': 'FR32123456789', 'gb': 'GB123456782', 'pt': 'PT123456789', 'ro': 'RO1234567897',
'gr': 'GR12345670', 'hu': 'HU12345676', 'se': 'SE123456789701', 'si': 'SI12345679',
'ie': 'IE1234567T', 'it': 'IT12345670017', 'sk': 'SK0012345675', 'el': 'EL12345670' ,
'lt': 'LT123456715', 'lu': 'LU12345613', 'za': 'ZA1234567890'
'lv': 'LV41234567891', 'mt': 'MT12345634', }
'nl': 'NL123456782B90', 'pl': 'PL1234567883', def mult_add(i, j):
'pt': 'PT123456789', 'ro': 'RO1234567897', """Sum each digits of the multiplication of i and j."""
'se': 'SE123456789701', 'si': 'SI12345679', return reduce(lambda x, y: x + int(y), str(i*j), 0)
class res_partner(osv.osv):
_inherit = 'res.partner'
def _split_vat(self, vat):
vat_country, vat_number = vat[:2].lower(), vat[2:].replace(' ', '')
return vat_country, vat_number
return {'value': {'vat_subjected': bool(value)}}
_columns = {
'vat_subjected': fields.boolean('VAT Legal Statement', help="Check this box if the partner is subjected to the VA$
}
def _construct_constraint_msg(self, cr, uid, ids, context=None):
def default_vat_check(cn, vn):
# by default, a VAT number is valid if:
# it starts with 2 letters
# has more than 3 characters
return cn[0] in string.ascii_lowercase and cn[1] in string.ascii_lowercase
vat_country, vat_number = self._split_vat(self.browse(cr, uid, ids)[0].vat)
if default_vat_check(vat_country, vat_number):
return False
return True
def vat_change(self, cr, uid, ids, value, context=None):
return {'value': {'vat_subjected': bool(value)}}
_columns = {
'vat_subjected': fields.boolean('VAT Legal Statement', help="Check this box if the partner is subjected to the VA$
}
def _construct_constraint_msg(self, cr, uid, ids, context=None):
def default_vat_check(cn, vn):
# by default, a VAT number is valid if:
# it starts with 2 letters
# has more than 3 characters
return cn[0] in string.ascii_lowercase and cn[1] in string.ascii_lowercase
vat_country, vat_number = self._split_vat(self.browse(cr, uid, ids)[0].vat)
if default_vat_check(vat_country, vat_number):
vat_no = vat_country in _ref_vat and _ref_vat[vat_country] or 'Country Code + Vat Number'
return _('The Vat does not seems to be correct. You should have entered something like this %s'), (vat_no)
return _('The VAT is invalid, It should begin with the country code'), ()
_constraints = [(check_vat, _construct_constraint_msg, ["vat"])]
# code from the following methods come from Tryton (B2CK)
#
http://www.tryton.org/hgwebdir.cgi/modu ... 9/party.py def check_vat_za(self, vat):
'''
Check South African VAT number. Now only reports True, to be filled with exact code to check the VAT number
'''
if len(vat) != 12:
return False
return True