It is currently Tue May 22, 2012 11:38 pm

All times are UTC + 2 hours




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: base_vat
PostPosted: Fri Jul 01, 2011 9:30 pm 
Offline

Joined: Mon Nov 29, 2010 1:31 pm
Posts: 112
Location: Polokwane , South Africa
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
Lawrence


import 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


Top
 Profile  
 
 Post subject: Re: base_vat
PostPosted: Thu Jul 07, 2011 10:29 pm 
Offline

Joined: Wed Jan 27, 2010 6:21 pm
Posts: 797
Location: Auckland, NZ
FWIW for Australia / NZ where we have GST and not VAT, we just created a seperate module that we install instead of base_vat. Base_vat is really pointless unless you are in EU IMO.

Just change my module columns from GST to VAT and everything will work, unless you have installed a chart of accounts which depends on base_vat (some badly written ones do).

We don't bother doing any checking, as it is not our responsibility to ensure it is correct, but our customers. But it is easy to add that checking.

res_partner_gst the module is called. lp:~gdgellatly/openerp-au/partner-gst

_________________
Graeme


Top
 Profile  
 
 Post subject: Re: base_vat
PostPosted: Fri Jul 08, 2011 2:11 pm 
Offline

Joined: Mon Nov 29, 2010 1:31 pm
Posts: 112
Location: Polokwane , South Africa
@gdaddy

Thank you so much

I can now finish a week on a very good note ..

regards

Lawrence

ps Enjoy the rugby


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC + 2 hours


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:

Protected by Anti-Spam ACP