Merge lp:~vauxoo/openerp-venezuela-localization/miguel-fiscal-requirements-imp into lp:~openerp-venezuela/openerp-venezuela-localization/6.0-trunk

Proposed by Miguel Delgado (Vauxoo)
Status: Merged
Merged at revision: 618
Proposed branch: lp:~vauxoo/openerp-venezuela-localization/miguel-fiscal-requirements-imp
Merge into: lp:~openerp-venezuela/openerp-venezuela-localization/6.0-trunk
Diff against target: 296 lines (+38/-116)
9 files modified
l10n_ve_fiscal_requirements/installer.py (+3/-3)
l10n_ve_fiscal_requirements/installer_view.xml (+1/-1)
l10n_ve_fiscal_requirements/partner.py (+4/-66)
l10n_ve_fiscal_requirements/seniat_url.py (+2/-3)
l10n_ve_fiscal_requirements/view/partner_view.xml (+0/-1)
l10n_ve_fiscal_requirements/wizard/search_info_partner_seniat.py (+4/-17)
l10n_ve_fiscal_requirements/wizard/search_info_partner_seniat.xml (+7/-2)
l10n_ve_withholding_islr/partner.py (+0/-4)
l10n_ve_withholding_iva/model/partner.py (+17/-19)
To merge this branch: bzr merge lp:~vauxoo/openerp-venezuela-localization/miguel-fiscal-requirements-imp
Reviewer Review Type Date Requested Status
Gabriela Quilarque Pending
Review via email: mp+93232@code.launchpad.net
To post a comment you must log in.
619. By Miguel Delgado (Vauxoo)

[FIX] placing the wizard to consult the rif of the partners in the right place for ergonomic use

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'l10n_ve_fiscal_requirements/installer.py'
2--- l10n_ve_fiscal_requirements/installer.py 2012-01-19 02:07:57 +0000
3+++ l10n_ve_fiscal_requirements/installer.py 2012-02-16 19:56:39 +0000
4@@ -38,7 +38,7 @@
5 context = {'exec_wizard': True, 'vat': vat}
6
7 partner_info = self.pool.get('seniat.url').update_rif(cr, uid, ids, context)
8- v = {'name': partner_info.get('name'), 'vat_apply': partner_info.get('vat_apply')}
9+ v = {'name': partner_info.get('name'), 'vat_subjected': partner_info.get('vat_subjected')}
10 return {'value': v}
11
12 def execute(self, cr, uid, ids, context=None):
13@@ -63,13 +63,13 @@
14 'street':wiz_data.add,
15 'country_id':self.pool.get("res.country").search(cr,uid,[('code','=','VE')])[0]})
16 #Data on res.partner
17- data = {'name': wiz_data.name, 'vat': "VE%s" % wiz_data.vat.upper(), 'vat_apply': wiz_data.vat_apply,}
18+ data = {'name': wiz_data.name, 'vat': "VE%s" % wiz_data.vat.upper(), 'vat_subjected': wiz_data.vat_subjected,}
19 self.pool.get('res.partner').write(cr, uid, [partner.id], data)
20
21 _columns = {
22 'vat': fields.char('VAT', 16, required=True, help='Partner\'s VAT to update the other fields'),
23 'name': fields.char('Name', 64, help="The commercial name of the company"),
24 'add':fields.char('Invoice Address',64,help='Put Here the address declared on your VAT information on SENIAT',required=True),
25- 'vat_apply': fields.boolean("Apply VAT?"),
26+ 'vat_subjected': fields.boolean("Apply VAT?"),
27 }
28 fiscal_requirements_config()
29
30=== modified file 'l10n_ve_fiscal_requirements/installer_view.xml'
31--- l10n_ve_fiscal_requirements/installer_view.xml 2011-10-25 20:33:16 +0000
32+++ l10n_ve_fiscal_requirements/installer_view.xml 2012-02-16 19:56:39 +0000
33@@ -31,7 +31,7 @@
34 <newline/>
35 <field name="name" groups="base.group_extended"/>
36 <newline/>
37- <field name="vat_apply" groups="base.group_extended" />
38+ <field name="vat_subjected" groups="base.group_extended" />
39 <newline/>
40 <field name="add" groups="base.group_extended" widget="text"/>
41 </group>
42
43=== modified file 'l10n_ve_fiscal_requirements/partner.py'
44--- l10n_ve_fiscal_requirements/partner.py 2012-01-27 15:30:52 +0000
45+++ l10n_ve_fiscal_requirements/partner.py 2012-02-16 19:56:39 +0000
46@@ -63,7 +63,6 @@
47 _inherit = 'res.partner'
48
49 _columns = {
50- 'vat_apply': fields.boolean('Vat Apply', help="This field indicate if partner is subject to vat apply "),
51 'seniat_updated': fields.boolean('Seniat Updated', help="This field indicates if partner was updated using SENIAT button"),
52 }
53
54@@ -150,72 +149,11 @@
55 return False
56 return True
57
58-# Update Partner Information
59-
60- def _load_url(self,retries,url):
61- str_error= '404 Not Found'
62- while retries > 0:
63- try:
64- s = urllib.urlopen(url)
65- r = s.read()
66- ok = not('404 Not Found' in r)
67- if ok:
68- self.logger.notifyChannel("info", netsvc.LOG_INFO,
69- "Url Loaded correctly %s" % url)
70- return r
71- except:
72- self.logger.notifyChannel("warning", netsvc.LOG_WARNING,
73- "Url could not be loaded %s" % str_error)
74- pass
75- retries -= 1
76- return str_error
77-
78- def _parse_dom(self,dom,rif,url_seniat):
79- name = dom.childNodes[0].childNodes[0].firstChild.data
80- vat_apply = dom.childNodes[0].childNodes[2].firstChild.data.upper()=='SI' and True or False
81- self.logger.notifyChannel("info", netsvc.LOG_INFO,
82- "RIF: %s Found" % rif)
83- if name.count('(') > 0:
84- name = name[:name.index('(')].rstrip()
85- return {'name': name,'vat_apply': vat_apply}
86-
87- def _print_error(self, error, msg):
88- raise osv.except_osv(error,msg)
89-
90- def _eval_seniat_data(self,xml_data,context={}):
91-
92- if xml_data.find('450')>=0:
93- if not 'all_rif' in context:
94- self._print_error(_('Vat Error !'),_('Invalid VAT!'))
95- else:
96- return True
97-
98- if xml_data.find('452')>=0:
99- if not 'all_rif' in context:
100- self._print_error(_('Vat Error !'),_('Unregistered VAT!'))
101- else:
102- return True
103-
104- if xml_data.find("404")>=0:
105- self._print_error(_('No Connection !'),_("Could not connect! Check the URL "))
106- return True
107-
108- def _dom_giver(self, url1, url2, context, vat):
109- xml_data = self._load_url(3,url1 % vat)
110- if not self._eval_seniat_data(xml_data,context):
111- dom = parseString(xml_data)
112- return self._parse_dom(dom, vat, url2)
113- else:
114- return False
115-
116- def _update_partner(self, cr, uid, id, context=None):
117- self.write(cr, uid, id, {'seniat_updated': True})
118-
119- def update_rif(self, cr, uid, ids, context={}):
120+ def update_rif(self, cr, uid, ids, context=None):
121+ if context is None:
122+ context = {}
123 su_obj = self.pool.get('seniat.url')
124- ctx = context.copy()
125- su_obj.connect_seniat(cr, uid, ids, context=ctx)
126- return True
127+ return su_obj.update_rif(cr, uid, ids, context=context)
128
129 res_partner()
130 # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
131
132=== modified file 'l10n_ve_fiscal_requirements/seniat_url.py'
133--- l10n_ve_fiscal_requirements/seniat_url.py 2012-02-14 14:33:22 +0000
134+++ l10n_ve_fiscal_requirements/seniat_url.py 2012-02-16 19:56:39 +0000
135@@ -78,13 +78,12 @@
136
137 def _parse_dom(self,dom,rif,url_seniat):
138 name = dom.childNodes[0].childNodes[0].firstChild.data
139- wh_iva_agent = dom.childNodes[0].childNodes[1].firstChild.data.upper()=='SI' and True or False
140- vat_apply = dom.childNodes[0].childNodes[2].firstChild.data.upper()=='SI' and True or False
141+ vat_subjected = dom.childNodes[0].childNodes[2].firstChild.data.upper()=='SI' and True or False
142 self.logger.notifyChannel("info", netsvc.LOG_INFO,
143 "RIF: %s Found" % rif)
144 if name.count('(') > 0:
145 name = name[:name.index('(')].rstrip()
146- res= {'name': name,'vat_apply': vat_apply,'wh_iva_agent': wh_iva_agent,'wh_iva_rate':self._buscar_porcentaje(rif,url_seniat)}
147+ res= {'name': name,'vat_subjected': vat_subjected,}
148 return res
149
150 def _print_error(self, error, msg):
151
152=== modified file 'l10n_ve_fiscal_requirements/view/partner_view.xml'
153--- l10n_ve_fiscal_requirements/view/partner_view.xml 2012-01-19 01:37:26 +0000
154+++ l10n_ve_fiscal_requirements/view/partner_view.xml 2012-02-16 19:56:39 +0000
155@@ -8,7 +8,6 @@
156 <field name="inherit_id" ref="base_vat.view_partner_form"/>
157 <field name="arch" type="xml">
158 <field name="vat" position="replace">
159- <field name="vat_apply"/>
160 </field>
161 </field>
162 </record>
163
164=== modified file 'l10n_ve_fiscal_requirements/wizard/search_info_partner_seniat.py'
165--- l10n_ve_fiscal_requirements/wizard/search_info_partner_seniat.py 2012-02-13 21:02:05 +0000
166+++ l10n_ve_fiscal_requirements/wizard/search_info_partner_seniat.py 2012-02-16 19:56:39 +0000
167@@ -31,24 +31,11 @@
168 _columns = {
169 'vat':fields.char('Numero de RIF', size=64, help='El RIF debe poseer el formato J1234567890',required=True),
170 'name':fields.char('Empresa / Persona', size=256, help='Nombre de la Empresa'),
171-# 'vat_subjected':fields.boolean('Agente de Retencion', help='Es Agente de Retencion'),
172+ 'wh_iva_agent':fields.boolean('Agente de Retencion', help='Es Agente de Retencion'),
173 'wh_iva_rate':fields.float('Porcentaje de Retencion', help='Porcentaje de Retencion Aplicable'),
174- 'vat_apply':fields.boolean('Contribuyente Formal', help='Es Contribuyente'),
175+ 'vat_subjected':fields.boolean('Contribuyente Formal', help='Es Contribuyente'),
176 }
177-
178- def _buscar_porcentaje(self,rif,url):
179- context={}
180- html_data = self.pool.get('seniat.url')._load_url(3,url %rif)
181- html_data = unicode(html_data, 'ISO-8859-1').encode('utf-8')
182- search_str='La condición de este contribuyente requiere la retención del '
183- pos = html_data.find(search_str)
184- if pos > 0:
185- pos += len(search_str)
186- pct = html_data[pos:pos+4].replace('%','').replace(' ','')
187- return float(pct)
188- else:
189- return 0.0
190-
191+
192 def search_partner_seniat(self, cr, uid, vat, context=None):
193 if context is None:
194 context={}
195@@ -61,7 +48,7 @@
196 if var_vat:
197 aux = var_vat[0]['vat']
198 res = su_obj._dom_giver(url1, url2, context, aux)
199- res.update({'wh_iva_rate':self._buscar_porcentaje(aux,url2)})
200+ res.update({'wh_iva_rate':su_obj._buscar_porcentaje(aux,url2)})
201 self.write(cr,uid,vat,res)
202
203 return False
204
205=== modified file 'l10n_ve_fiscal_requirements/wizard/search_info_partner_seniat.xml'
206--- l10n_ve_fiscal_requirements/wizard/search_info_partner_seniat.xml 2012-02-13 21:02:05 +0000
207+++ l10n_ve_fiscal_requirements/wizard/search_info_partner_seniat.xml 2012-02-16 19:56:39 +0000
208@@ -16,7 +16,7 @@
209 <field name="name" readonly='True'/>
210 <field name="wh_iva_agent" readonly='True'/>
211 <field name="wh_iva_rate" readonly='True'/>
212- <field name="vat_apply" readonly='True'/>
213+ <field name="vat_subjected" readonly='True'/>
214 </group>
215 </form>
216 </field>
217@@ -31,8 +31,13 @@
218 <field name="target">new</field>
219 </record>
220
221+
222 <menuitem name="Search RIF" id="wizard_vat_search_action_menu"
223- parent="l10n_ve_fiscal_requirements.menu_finance_partner_fiscal_information" action="wizard_vat_search_action"
224+ parent="account.menu_finance_receivables" action="wizard_vat_search_action"
225+ sequence="400"/>
226+
227+ <menuitem name="Search RIF" id="wizard_vat_search_action_pay_menu"
228+ parent="account.menu_finance_payables" action="wizard_vat_search_action"
229 sequence="400"/>
230
231 </data>
232
233=== modified file 'l10n_ve_withholding_islr/partner.py'
234--- l10n_ve_withholding_islr/partner.py 2011-11-28 15:07:46 +0000
235+++ l10n_ve_withholding_islr/partner.py 2012-02-16 19:56:39 +0000
236@@ -40,10 +40,6 @@
237 'islr_withholding_agent': fields.boolean('Withholding Income Agent?',help="Check if the partner is an agent for withholding income"),
238 }
239
240- _defaults = {
241- 'islr_withholding_agent': 1,
242- }
243-
244 res_partner()
245
246
247
248=== modified file 'l10n_ve_withholding_iva/model/partner.py'
249--- l10n_ve_withholding_iva/model/partner.py 2012-01-25 16:56:12 +0000
250+++ l10n_ve_withholding_iva/model/partner.py 2012-02-16 19:56:39 +0000
251@@ -39,28 +39,26 @@
252 _defaults = {
253 'wh_iva_rate': lambda *a: 0,
254 }
255-
256-
257- def _buscar_porcentaje(self,rif,url):
258- context={}
259- html_data = self._load_url(3,url %rif)
260- html_data = unicode(html_data, 'ISO-8859-1').encode('utf-8')
261- self._eval_seniat_data(html_data,context)
262- search_str='La condición de este contribuyente requiere la retención del '
263- pos = html_data.find(search_str)
264- if pos > 0:
265- pos += len(search_str)
266- pct = html_data[pos:pos+4].replace('%','').replace(' ','')
267- return float(pct)
268- else:
269- return 0.0
270-
271+
272+ def update_rif(self, cr, uid, ids, context=None):
273+ if context is None:
274+ context = {}
275+ su_obj = self.pool.get('seniat.url')
276+ return su_obj.update_rif(cr, uid, ids, context=context)
277+
278+res_partner()
279+
280+class seniat_url(osv.osv):
281+
282+ _inherit = 'seniat.url'
283+
284 def _parse_dom(self,dom,rif,url_seniat):
285+ su_obj = self.pool.get('seniat.url')
286 wh_agent = dom.childNodes[0].childNodes[1].firstChild.data.upper()=='SI' and True or False
287- wh_rate = self._buscar_porcentaje(rif,url_seniat)
288+ wh_rate = su_obj._buscar_porcentaje(rif,url_seniat)
289 self.logger.notifyChannel("info", netsvc.LOG_INFO,
290 "RIF: %s Found" % rif)
291 data = {'wh_iva_agent':wh_agent,'wh_iva_rate':wh_rate}
292- return dict(data.items() + super(res_partner,self)._parse_dom(dom,rif,url_seniat).items())
293+ return dict(data.items() + super(seniat_url,self)._parse_dom(dom,rif,url_seniat).items())
294
295-res_partner()
296+seniat_url()