Merge lp:~vauxoo/openerp-venezuela-localization/miguel-partner-info-fr-whi into lp:~openerp-venezuela/openerp-venezuela-localization/6.0-trunk
- miguel-partner-info-fr-whi
- Merge into 6.0-trunk
Proposed by
Miguel Delgado (Vauxoo)
Status: | Merged |
---|---|
Merged at revision: | 436 |
Proposed branch: | lp:~vauxoo/openerp-venezuela-localization/miguel-partner-info-fr-whi |
Merge into: | lp:~openerp-venezuela/openerp-venezuela-localization/6.0-trunk |
Diff against target: |
370 lines (+104/-169) 10 files modified
l10n_ve_fiscal_requirements/__openerp__.py (+1/-0) l10n_ve_fiscal_requirements/partner.py (+27/-6) l10n_ve_fiscal_requirements/wizard/__init__.py (+1/-0) l10n_ve_fiscal_requirements/wizard/update_info_partner.py (+40/-0) l10n_ve_fiscal_requirements/wizard/update_info_partner.xml (+35/-0) l10n_ve_withholding_iva/__openerp__.py (+0/-1) l10n_ve_withholding_iva/partner.py (+0/-65) l10n_ve_withholding_iva/wizard/__init__.py (+0/-22) l10n_ve_withholding_iva/wizard/update_info_partner.py (+0/-40) l10n_ve_withholding_iva/wizard/update_info_partner.xml (+0/-35) |
To merge this branch: | bzr merge lp:~vauxoo/openerp-venezuela-localization/miguel-partner-info-fr-whi |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Javier Duran (community) | Approve | ||
Review via email: mp+79018@code.launchpad.net |
Commit message
Description of the change
[ADD] the functionality to update all partner info into the module l10n_ve_
To post a comment you must log in.
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'l10n_ve_fiscal_requirements/__openerp__.py' |
2 | --- l10n_ve_fiscal_requirements/__openerp__.py 2011-10-10 01:50:28 +0000 |
3 | +++ l10n_ve_fiscal_requirements/__openerp__.py 2011-10-11 19:26:23 +0000 |
4 | @@ -64,6 +64,7 @@ |
5 | 'wizard/wizard_invoice_nro_ctrl_view.xml', |
6 | 'wizard/wizard_nro_ctrl_view.xml', |
7 | 'wizard/wizard_url_seniat_view.xml', |
8 | + 'wizard/update_info_partner.xml', |
9 | ], |
10 | 'demo_xml': [ |
11 | 'demo/demo_partners.xml', |
12 | |
13 | === modified file 'l10n_ve_fiscal_requirements/partner.py' |
14 | --- l10n_ve_fiscal_requirements/partner.py 2011-10-09 19:18:15 +0000 |
15 | +++ l10n_ve_fiscal_requirements/partner.py 2011-10-11 19:26:23 +0000 |
16 | @@ -141,14 +141,22 @@ |
17 | raise osv.except_osv(error,msg) |
18 | |
19 | def _eval_seniat_data(self,xml_data,context={}): |
20 | + |
21 | if xml_data.find('450')>=0: |
22 | - self._print_error(_('Vat Error !'),_('Invalid VAT!')) |
23 | + if not 'all_rif' in context: |
24 | + self._print_error(_('Vat Error !'),_('Invalid VAT!')) |
25 | + else: |
26 | + return True |
27 | |
28 | if xml_data.find('452')>=0: |
29 | - self._print_error(_('Vat Error !'),_('Unregistered VAT!')) |
30 | + if not 'all_rif' in context: |
31 | + self._print_error(_('Vat Error !'),_('Unregistered VAT!')) |
32 | + else: |
33 | + return True |
34 | |
35 | if xml_data.find("404")>=0: |
36 | self._print_error(_('No Connection !'),_("Could not connect! Check the URL ")) |
37 | + return True |
38 | |
39 | |
40 | def _dom_giver(self, url1, url2, context, vat): |
41 | @@ -166,12 +174,25 @@ |
42 | url2 = url_obj.url_seniat + '%s' |
43 | if context.get('exec_wizard'): |
44 | return self._dom_giver(url1, url2, context, context['vat']) |
45 | - |
46 | for partner in self.browse(cr,uid,ids): |
47 | if partner.vat: |
48 | - data = self._dom_giver(url1, url2, context, partner.vat[2:]) |
49 | - print data |
50 | - self.write(cr,uid,partner.id,data) |
51 | + xml_data = self._load_url(3,url1 %partner.vat[2:]) |
52 | + if not self._eval_seniat_data(xml_data,context): |
53 | + dom = parseString(xml_data) |
54 | + self.write(cr,uid,partner.id,self._parse_dom(dom,partner.vat[2:],url2)) |
55 | + else: |
56 | + return False |
57 | + else: |
58 | + if not 'all_rif' in context: |
59 | + self._print_error(_('Vat Error !'),_('The field vat is empty')) |
60 | + return True |
61 | + |
62 | + def connect_seniat(self, cr, uid, ids, context={}, all_rif=False): |
63 | + if all_rif: |
64 | + ctx = context.copy() |
65 | + ctx.update({'all_rif': True}) |
66 | + for partner in self.browse(cr,uid,ids): |
67 | + self.update_rif(cr, uid, [partner.id], context=ctx) |
68 | return True |
69 | |
70 | res_partner() |
71 | |
72 | === modified file 'l10n_ve_fiscal_requirements/wizard/__init__.py' |
73 | --- l10n_ve_fiscal_requirements/wizard/__init__.py 2011-10-09 17:01:04 +0000 |
74 | +++ l10n_ve_fiscal_requirements/wizard/__init__.py 2011-10-11 19:26:23 +0000 |
75 | @@ -26,3 +26,4 @@ |
76 | import wizard_nro_ctrl |
77 | import wizard_invoice_nro_ctrl |
78 | import wizard_url_seniat |
79 | +import update_info_partner |
80 | |
81 | === added file 'l10n_ve_fiscal_requirements/wizard/update_info_partner.py' |
82 | --- l10n_ve_fiscal_requirements/wizard/update_info_partner.py 1970-01-01 00:00:00 +0000 |
83 | +++ l10n_ve_fiscal_requirements/wizard/update_info_partner.py 2011-10-11 19:26:23 +0000 |
84 | @@ -0,0 +1,40 @@ |
85 | +# -*- encoding: utf-8 -*- |
86 | +############################################################################## |
87 | +# |
88 | +# OpenERP, Open Source Management Solution |
89 | +# Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). All Rights Reserved |
90 | +# author.name@company.com |
91 | +# |
92 | +# This program is free software: you can redistribute it and/or modify |
93 | +# it under the terms of the GNU General Public License as published by |
94 | +# the Free Software Foundation, either version 3 of the License, or |
95 | +# (at your option) any later version. |
96 | +# |
97 | +# This program is distributed in the hope that it will be useful, |
98 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
99 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
100 | +# GNU General Public License for more details. |
101 | +# |
102 | +# You should have received a copy of the GNU General Public License |
103 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. |
104 | +# |
105 | +############################################################################## |
106 | +import wizard |
107 | +import pooler |
108 | +from osv import osv, fields |
109 | +from tools.translate import _ |
110 | + |
111 | +class update_info_partner(osv.osv_memory): |
112 | + """ |
113 | + OpenERP osv memory wizard : update_info_partner |
114 | + """ |
115 | + _name = 'update.info.partner' |
116 | + |
117 | + def update_info(self, cr, uid, ids, context={}): |
118 | + res_part_obj = self.pool.get('res.partner') |
119 | + es_partner_ids= res_part_obj.search(cr, uid, []) |
120 | + res_part_obj.connect_seniat(cr, uid, es_partner_ids, context,True) |
121 | + return{} |
122 | + |
123 | + |
124 | +update_info_partner() |
125 | |
126 | === added file 'l10n_ve_fiscal_requirements/wizard/update_info_partner.xml' |
127 | --- l10n_ve_fiscal_requirements/wizard/update_info_partner.xml 1970-01-01 00:00:00 +0000 |
128 | +++ l10n_ve_fiscal_requirements/wizard/update_info_partner.xml 2011-10-11 19:26:23 +0000 |
129 | @@ -0,0 +1,35 @@ |
130 | +<?xml version="1.0" encoding="utf-8"?> |
131 | +<openerp> |
132 | + <data> |
133 | + |
134 | + <menuitem id="menu_finance_partner_fiscal_information" name="Partner Fiscal Information" parent="account.menu_finance" groups="account.group_account_manager"/> |
135 | + |
136 | + <record id="view_wizard_update_info_partner" model="ir.ui.view"> |
137 | + <field name="name">view.update.info.partner</field> |
138 | + <field name="model">update.info.partner</field> |
139 | + <field name="type">form</field> |
140 | + <field name="arch" type="xml"> |
141 | + <form string=""> |
142 | + <separator string="Are you sure you want to do this?" colspan="4"/> |
143 | + <group colspan="8" col="8"> |
144 | + <button icon="gtk-ok" name="update_info" type="object" string="Yes"/> |
145 | + <button icon="gtk-cancel" special="cancel" string="No"/> |
146 | + </group> |
147 | + </form> |
148 | + </field> |
149 | + </record> |
150 | + |
151 | + <record id="wizard_update_info_partner" model="ir.actions.act_window"> |
152 | + <field name="name">Update Info Partner</field> |
153 | + <field name="res_model">update.info.partner</field> |
154 | + <field name="view_type">form</field> |
155 | + <field name="view_mode">form</field> |
156 | + <field name="view_id" ref="view_wizard_update_info_partner"/> |
157 | + <field name="target">new</field> |
158 | + </record> |
159 | + |
160 | + <menuitem name="Update All Partner Information" id="wizard_update_all_partner_information" |
161 | + parent="menu_finance_partner_fiscal_information" action="wizard_update_info_partner" |
162 | + /> |
163 | + </data> |
164 | +</openerp> |
165 | |
166 | === modified file 'l10n_ve_withholding_iva/__openerp__.py' |
167 | --- l10n_ve_withholding_iva/__openerp__.py 2011-10-06 17:08:59 +0000 |
168 | +++ l10n_ve_withholding_iva/__openerp__.py 2011-10-11 19:26:23 +0000 |
169 | @@ -46,7 +46,6 @@ |
170 | "account_workflow.xml", |
171 | "l10n_ve_withholding_iva_installer.xml", |
172 | "account_workflow.xml", |
173 | - "wizard/update_info_partner.xml", |
174 | ], |
175 | 'demo_xml': ["demo/l10n_ve_withholding_iva_demo.xml"], |
176 | 'test': [], |
177 | |
178 | === modified file 'l10n_ve_withholding_iva/partner.py' |
179 | --- l10n_ve_withholding_iva/partner.py 2011-10-09 17:45:08 +0000 |
180 | +++ l10n_ve_withholding_iva/partner.py 2011-10-11 19:26:23 +0000 |
181 | @@ -56,23 +56,6 @@ |
182 | |
183 | } |
184 | |
185 | - def _load_url(self,retries,url): |
186 | - str_error= '404 Not Found' |
187 | - while retries > 0: |
188 | - try: |
189 | - s = urllib.urlopen(url) |
190 | - r = s.read() |
191 | - ok = not('404 Not Found' in r) |
192 | - if ok: |
193 | - self.logger.notifyChannel("info", netsvc.LOG_INFO, |
194 | - "Url Loaded correctly %s" % url) |
195 | - return r |
196 | - except: |
197 | - self.logger.notifyChannel("warning", netsvc.LOG_WARNING, |
198 | - "Url could not be loaded %s" % str_error) |
199 | - pass |
200 | - retries -= 1 |
201 | - return str_error |
202 | |
203 | def _buscar_porcentaje(self,rif,url): |
204 | context={} |
205 | @@ -95,53 +78,5 @@ |
206 | "RIF: %s Found" % rif) |
207 | data = {'wh_iva_agent':wh_agent,'wh_iva_rate':wh_rate} |
208 | return dict(data.items() + super(res_partner,self)._parse_dom(dom,rif,url_seniat).items()) |
209 | - |
210 | - def _print_error(self, error, msg): |
211 | - raise osv.except_osv(error,msg) |
212 | - |
213 | - def _eval_seniat_data(self,xml_data,context={}): |
214 | - |
215 | - if xml_data.find('450')>=0: |
216 | - if not 'all_rif' in context: |
217 | - self._print_error(_('Vat Error !'),_('Invalid VAT!')) |
218 | - else: |
219 | - return True |
220 | - |
221 | - if xml_data.find('452')>=0: |
222 | - if not 'all_rif' in context: |
223 | - self._print_error(_('Vat Error !'),_('Unregistered VAT!')) |
224 | - else: |
225 | - return True |
226 | - |
227 | - if xml_data.find("404")>=0: |
228 | - self._print_error(_('No Connection !'),_("Could not connect! Check the URL ")) |
229 | - return True |
230 | - |
231 | - def update_rif(self, cr, uid, ids, context={}): |
232 | - pool = self.pool.get('seniat.url') |
233 | - url_obj = pool.browse(cr, uid, pool.search(cr, uid, []))[0] |
234 | - url1 = url_obj.name + '%s' |
235 | - url2 = url_obj.url_seniat + '%s' |
236 | - for partner in self.browse(cr,uid,ids): |
237 | - if partner.vat: |
238 | - xml_data = self._load_url(3,url1 %partner.vat[2:]) |
239 | - if not self._eval_seniat_data(xml_data,context): |
240 | - dom = parseString(xml_data) |
241 | - self.write(cr,uid,partner.id,self._parse_dom(dom,partner.vat[2:],url2)) |
242 | - else: |
243 | - return False |
244 | - else: |
245 | - if not 'all_rif' in context: |
246 | - self._print_error(_('Vat Error !'),_('The field vat is empty')) |
247 | - return True |
248 | - |
249 | - def connect_seniat(self, cr, uid, ids, context={}, all_rif=False): |
250 | - if all_rif: |
251 | - ctx = context.copy() |
252 | - ctx.update({'all_rif': True}) |
253 | - for partner in self.browse(cr,uid,ids): |
254 | - self.update_rif(cr, uid, [partner.id], context=ctx) |
255 | - |
256 | - return True |
257 | |
258 | res_partner() |
259 | |
260 | === removed file 'l10n_ve_withholding_iva/wizard/__init__.py' |
261 | --- l10n_ve_withholding_iva/wizard/__init__.py 2011-10-04 21:06:55 +0000 |
262 | +++ l10n_ve_withholding_iva/wizard/__init__.py 1970-01-01 00:00:00 +0000 |
263 | @@ -1,22 +0,0 @@ |
264 | -# -*- encoding: utf-8 -*- |
265 | -############################################################################## |
266 | -# |
267 | -# OpenERP, Open Source Management Solution |
268 | -# Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). All Rights Reserved |
269 | -# author.name@company.com |
270 | -# |
271 | -# This program is free software: you can redistribute it and/or modify |
272 | -# it under the terms of the GNU General Public License as published by |
273 | -# the Free Software Foundation, either version 3 of the License, or |
274 | -# (at your option) any later version. |
275 | -# |
276 | -# This program is distributed in the hope that it will be useful, |
277 | -# but WITHOUT ANY WARRANTY; without even the implied warranty of |
278 | -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
279 | -# GNU General Public License for more details. |
280 | -# |
281 | -# You should have received a copy of the GNU General Public License |
282 | -# along with this program. If not, see <http://www.gnu.org/licenses/>. |
283 | -# |
284 | -############################################################################## |
285 | -import update_info_partner |
286 | |
287 | === removed file 'l10n_ve_withholding_iva/wizard/update_info_partner.py' |
288 | --- l10n_ve_withholding_iva/wizard/update_info_partner.py 2011-10-04 22:09:51 +0000 |
289 | +++ l10n_ve_withholding_iva/wizard/update_info_partner.py 1970-01-01 00:00:00 +0000 |
290 | @@ -1,40 +0,0 @@ |
291 | -# -*- encoding: utf-8 -*- |
292 | -############################################################################## |
293 | -# |
294 | -# OpenERP, Open Source Management Solution |
295 | -# Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). All Rights Reserved |
296 | -# author.name@company.com |
297 | -# |
298 | -# This program is free software: you can redistribute it and/or modify |
299 | -# it under the terms of the GNU General Public License as published by |
300 | -# the Free Software Foundation, either version 3 of the License, or |
301 | -# (at your option) any later version. |
302 | -# |
303 | -# This program is distributed in the hope that it will be useful, |
304 | -# but WITHOUT ANY WARRANTY; without even the implied warranty of |
305 | -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
306 | -# GNU General Public License for more details. |
307 | -# |
308 | -# You should have received a copy of the GNU General Public License |
309 | -# along with this program. If not, see <http://www.gnu.org/licenses/>. |
310 | -# |
311 | -############################################################################## |
312 | -import wizard |
313 | -import pooler |
314 | -from osv import osv, fields |
315 | -from tools.translate import _ |
316 | - |
317 | -class update_info_partner(osv.osv_memory): |
318 | - """ |
319 | - OpenERP osv memory wizard : update_info_partner |
320 | - """ |
321 | - _name = 'update.info.partner' |
322 | - |
323 | - def update_info(self, cr, uid, ids, context={}): |
324 | - res_part_obj = self.pool.get('res.partner') |
325 | - es_partner_ids= res_part_obj.search(cr, uid, []) |
326 | - res_part_obj.connect_seniat(cr, uid, es_partner_ids, context,True) |
327 | - return{} |
328 | - |
329 | - |
330 | -update_info_partner() |
331 | |
332 | === removed file 'l10n_ve_withholding_iva/wizard/update_info_partner.xml' |
333 | --- l10n_ve_withholding_iva/wizard/update_info_partner.xml 2011-10-04 21:23:37 +0000 |
334 | +++ l10n_ve_withholding_iva/wizard/update_info_partner.xml 1970-01-01 00:00:00 +0000 |
335 | @@ -1,35 +0,0 @@ |
336 | -<?xml version="1.0" encoding="utf-8"?> |
337 | -<openerp> |
338 | - <data> |
339 | - |
340 | - <menuitem id="menu_finance_partner_fiscal_information" name="Partner Fiscal Information" parent="account.menu_finance" groups="account.group_account_manager"/> |
341 | - |
342 | - <record id="view_wizard_update_info_partner" model="ir.ui.view"> |
343 | - <field name="name">view.update.info.partner</field> |
344 | - <field name="model">update.info.partner</field> |
345 | - <field name="type">form</field> |
346 | - <field name="arch" type="xml"> |
347 | - <form string=""> |
348 | - <separator string="Are you sure you want to do this?" colspan="4"/> |
349 | - <group colspan="8" col="8"> |
350 | - <button icon="gtk-ok" name="update_info" type="object" string="Yes"/> |
351 | - <button icon="gtk-cancel" special="cancel" string="No"/> |
352 | - </group> |
353 | - </form> |
354 | - </field> |
355 | - </record> |
356 | - |
357 | - <record id="wizard_update_info_partner" model="ir.actions.act_window"> |
358 | - <field name="name">Update Info Partner</field> |
359 | - <field name="res_model">update.info.partner</field> |
360 | - <field name="view_type">form</field> |
361 | - <field name="view_mode">form</field> |
362 | - <field name="view_id" ref="view_wizard_update_info_partner"/> |
363 | - <field name="target">new</field> |
364 | - </record> |
365 | - |
366 | - <menuitem name="Update All Partner Information" id="wizard_update_all_partner_information" |
367 | - parent="menu_finance_partner_fiscal_information" action="wizard_update_info_partner" |
368 | - /> |
369 | - </data> |
370 | -</openerp> |
Merged in trunk.
revno: 436 [merge] squezee- vir-20111011193 946-z7y26wnnuot 78xmk
revision-id: javier@