Merge lp:~openerp-community/openobject-addons/meanmicio_base_vat6 into lp:openobject-addons

Proposed by Luis Falcon - Thymbra
Status: Rejected
Rejected by: Fabien (Open ERP)
Proposed branch: lp:~openerp-community/openobject-addons/meanmicio_base_vat6
Merge into: lp:openobject-addons
Diff against target: 131 lines (+71/-9)
2 files modified
base_vat/base_vat.py (+66/-6)
base_vat/base_vat_view.xml (+5/-3)
To merge this branch: bzr merge lp:~openerp-community/openobject-addons/meanmicio_base_vat6
Reviewer Review Type Date Requested Status
qdp (OpenERP) Needs Information
Review via email: mp+41852@code.launchpad.net
To post a comment you must log in.
Revision history for this message
qdp (OpenERP) (qdp) wrote :

Hello Luis,

i checked this branch and i have a doubt on the utility of splitting the vat number in two parts: i don't see the added value of such a thing. Also i'm not sure we want the avoid verification feature in core module. For this, maybe an extra module would do the trick.

For the argentinian vat validation algorithm, i'd be glad to add it but could you please provide an example of a valid argentinian vat number in the _ref_vat dictionary? This could be usefull for tests but it is also used to display an accurate message when the encoded vat number is not correct.

review: Needs Information
Revision history for this message
qdp (OpenERP) (qdp) wrote :

i changed the status back to "work in progress" for the sake of clarity in LP.

Thanks for your contribution,
Quentin

Revision history for this message
Fabien (Open ERP) (fp-tinyerp) wrote :

Hello,

I changed the status to Rejected. You can do a new merge proposal once it's updated.

Unmerged revisions

3958. By lfm <lfm@beastie>

Add the following functionality
- Add Argentinian VAT number verification algorithm
- The VAT is calculated depending on the country.
- No need to insert the two letter code in the VAT number, since it's
not part of it anyways. Now the function will be calculated from the
country code taken from the VAT country name
- Added a verification flag, so you can avoid the verification if you want.
- Change the name of the file "base_vat_data.xml" to "base_vat_view.xml"

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'base_vat/base_vat.py'
--- base_vat/base_vat.py 2010-11-10 08:12:44 +0000
+++ base_vat/base_vat.py 2010-11-25 11:21:20 +0000
@@ -48,19 +48,39 @@
48class res_partner(osv.osv):48class res_partner(osv.osv):
49 _inherit = 'res.partner'49 _inherit = 'res.partner'
5050
51 def _split_vat(self, vat):51 def _split_vat(self, vat_country_code, vat):
52 vat_country, vat_number = vat[:2].lower(), vat[2:].replace(' ', '')52 vat_country, vat_number = vat_country_code.lower(), vat.replace(' ', '')
53 return vat_country, vat_number53 return vat_country, vat_number
5454
55 def check_vat(self, cr, uid, ids):55 def check_vat(self, cr, uid, ids):
56 '''56 '''
57 Check the VAT number depending of the country.57 Check the VAT number depending of the country.
58 http://sima-pc.com/nif.php58 http://sima-pc.com/nif.php
59 '''59
60 => Developers: make sure to add the country ISO 3166 code in the current_country_codes variable for each new vat code verification function
61 For more info about country ISO codes :
62 http://www.iso.org/iso/english_country_names_and_code_elements
63
64 Note that UK is just an alias for GB. Once it gets fixed on the global country code lists it should be removed.
65 '''
66
67 current_country_codes = ["AR","AT","BE","BG","CY","CZ","DE","DK","EE","EL","ES","FI","FR","GB","GR","HU","IE","IT","LT","LU","LV","MT","NL","PL","PT","RO","SE","SI","SK","UK"]
68
60 for partner in self.browse(cr, uid, ids):69 for partner in self.browse(cr, uid, ids):
61 if not partner.vat:70 if not partner.vat:
62 continue71 continue
63 vat_country, vat_number = self._split_vat(partner.vat)72
73 if not partner.vat_country:
74 continue
75
76 if not partner.verify_vat:
77 continue
78
79 if not partner.vat_country.code in current_country_codes:
80 continue
81
82 vat_country, vat_number = self._split_vat(partner.vat_country, partner.vat)
83
64 if not hasattr(self, 'check_vat_' + vat_country):84 if not hasattr(self, 'check_vat_' + vat_country):
65 return False85 return False
66 check = getattr(self, 'check_vat_' + vat_country)86 check = getattr(self, 'check_vat_' + vat_country)
@@ -72,7 +92,9 @@
72 return {'value': {'vat_subjected': bool(value)}}92 return {'value': {'vat_subjected': bool(value)}}
7393
74 _columns = {94 _columns = {
75 'vat_subjected': fields.boolean('VAT Legal Statement', help="Check this box if the partner is subjected to the VAT. It will be used for the VAT legal statement.")95 'vat_subjected': fields.boolean('VAT Legal Statement', help="Check this box if the partner is subjected to the VAT. It will be used for the VAT legal statement."),
96 'vat_country':fields.many2one('res.country','VAT Country',help="Country corresponding to this VAT number"),
97 'verify_vat': fields.boolean('Check VAT', help="Check this box if you want to check the validity of the VAT number. In that case, make sure you enter the Country Name of the partner and the correspondant VAT number"),
76 }98 }
7799
78 def _construct_constraint_msg(self, cr, uid, ids):100 def _construct_constraint_msg(self, cr, uid, ids):
@@ -81,7 +103,8 @@
81 # it starts with 2 letters103 # it starts with 2 letters
82 # has more than 3 characters104 # has more than 3 characters
83 return cn[0] in string.ascii_lowercase and cn[1] in string.ascii_lowercase105 return cn[0] in string.ascii_lowercase and cn[1] in string.ascii_lowercase
84 vat_country, vat_number = self._split_vat(self.browse(cr, uid, ids)[0].vat)106 partner_obj = self.browse(cr, uid, ids)[0]
107 vat_country, vat_number = self._split_vat(partner_obj.vat_country, partner_obj.vat)
85 if default_vat_check(vat_country, vat_number):108 if default_vat_check(vat_country, vat_number):
86 vat_no = vat_country in _ref_vat and _ref_vat[vat_country] or 'Country Code + Vat Number'109 vat_no = vat_country in _ref_vat and _ref_vat[vat_country] or 'Country Code + Vat Number'
87 return _('The Vat does not seems to be correct. You should have entered something like this %s'), (vat_no)110 return _('The Vat does not seems to be correct. You should have entered something like this %s'), (vat_no)
@@ -91,6 +114,43 @@
91114
92 # code from the following methods come from Tryton (B2CK)115 # code from the following methods come from Tryton (B2CK)
93 # http://www.tryton.org/hgwebdir.cgi/modules/relationship/file/544d1de586d9/party.py116 # http://www.tryton.org/hgwebdir.cgi/modules/relationship/file/544d1de586d9/party.py
117
118 def check_vat_ar(self, vat):
119 '''
120 Check VAT (CUIT) for Argentina - Thymbra.
121 '''
122
123 cstr = str (vat)
124 salt=str (5432765432)
125 n=0
126 sum=0
127
128 if not vat.isdigit:
129 return False
130
131 if (len (vat) <> 11):
132 return False
133
134 while (n < 10):
135 sum = sum + int (salt[n]) * int (cstr[n])
136 n=n+1
137
138 op1 = sum % 11
139 op2 = 11 - op1
140
141 codigo_verificador = op2
142
143 if ( op2 == 11 or op2 == 10):
144 if ( op2 == 11 ):
145 codigo_verificador = 0
146 else:
147 codigo_verificador = 9
148
149 if ( codigo_verificador == int (cstr[10]) ):
150 return True
151 else:
152 return False
153
94 def check_vat_at(self, vat):154 def check_vat_at(self, vat):
95 '''155 '''
96 Check Austria VAT number.156 Check Austria VAT number.
97157
=== modified file 'base_vat/base_vat_view.xml'
--- base_vat/base_vat_view.xml 2010-05-25 14:01:13 +0000
+++ base_vat/base_vat_view.xml 2010-11-25 11:21:20 +0000
@@ -8,9 +8,11 @@
8 <field name="inherit_id" ref="account.view_partner_property_form"/>8 <field name="inherit_id" ref="account.view_partner_property_form"/>
9 <field name="arch" type="xml">9 <field name="arch" type="xml">
10 <field name="property_account_payable" position="after">10 <field name="property_account_payable" position="after">
11 <group colspan="2" col="6">11 <group colspan="2" col="4">
12 <field name="vat" on_change="vat_change(vat)" colspan="4" />12 <field name="vat_country" select="2"/>
13 <field name="vat_subjected" colspan="1"/>13 <field name="vat" on_change="vat_change(vat)" colspan="4" />
14 <field name="vat_subjected" colspan="1"/>
15 <field name="verify_vat"/>
14 </group>16 </group>
15 </field>17 </field>
16 </field>18 </field>

Subscribers

People subscribed via source and target branches

to all changes: