Merge lp:~vauxoo/openerp-venezuela-localization/miguel-update-partner-info-seniat-bug into lp:~openerp-venezuela/openerp-venezuela-localization/6.0-trunk

Proposed by Miguel Delgado (Vauxoo)
Status: Merged
Merged at revision: 614
Proposed branch: lp:~vauxoo/openerp-venezuela-localization/miguel-update-partner-info-seniat-bug
Merge into: lp:~openerp-venezuela/openerp-venezuela-localization/6.0-trunk
Diff against target: 111 lines (+27/-23)
3 files modified
l10n_ve_fiscal_requirements/seniat_url.py (+19/-21)
l10n_ve_fiscal_requirements/wizard/update_info_partner.py (+7/-1)
l10n_ve_topology/module/sector.py (+1/-1)
To merge this branch: bzr merge lp:~vauxoo/openerp-venezuela-localization/miguel-update-partner-info-seniat-bug
Reviewer Review Type Date Requested Status
Gabriela Quilarque Approve
Review via email: mp+92563@code.launchpad.net

Description of the change

[FIX] bug when we try to update fiscal partner information
when partner vat contain string "450" the wizard dont work

To post a comment you must log in.
Revision history for this message
Gabriela Quilarque (gabrielaquilarque97) wrote :

Migue por favor elimina los prints.

review: Needs Fixing
613. By Miguel Delgado (Vauxoo)

[IMP] drop prints in this files seniat_url.py and update_info_partner.py

Revision history for this message
Gabriela Quilarque (gabrielaquilarque97) wrote :

Listo. Merge Ejecutado.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'l10n_ve_fiscal_requirements/seniat_url.py'
--- l10n_ve_fiscal_requirements/seniat_url.py 2012-02-13 21:02:05 +0000
+++ l10n_ve_fiscal_requirements/seniat_url.py 2012-02-14 14:26:29 +0000
@@ -90,31 +90,30 @@
90 def _print_error(self, error, msg):90 def _print_error(self, error, msg):
91 raise osv.except_osv(error,msg)91 raise osv.except_osv(error,msg)
9292
93 def _eval_seniat_data(self,xml_data,context={}):93 def _eval_seniat_data(self,xml_data,vat,context={}):
94 if context is None:94 if context is None:
95 context={}95 context={}
96 if not context.get('all_rif'):96 if not context.get('all_rif'):
97 if xml_data.find('450')>=0:97 if xml_data.find('450')>=0 and not vat.find('450'):
98 if not 'all_rif' in context:98 self._print_error(_('Vat Error !'),_('Invalid VAT!'))
99 self._print_error(_('Vat Error !'),_('Invalid VAT!'))99
100 else:100 elif xml_data.find('452')>=0 and not vat.find('452'):
101 return True101 self._print_error(_('Vat Error !'),_('Unregistered VAT!'))
102102
103 if xml_data.find('452')>=0:103 elif xml_data.find("404")>=0 and not vat.find('404'):
104 if not 'all_rif' in context:
105 self._print_error(_('Vat Error !'),_('Unregistered VAT!'))
106 else:
107 return True
108
109 if xml_data.find("404")>=0:
110 self._print_error(_('No Connection !'),_("Could not connect! Check the URL "))104 self._print_error(_('No Connection !'),_("Could not connect! Check the URL "))
105
106 else:
107 return False
108 else:
109 if xml_data.find('450')>=0 or xml_data.find('452')>=0 or xml_data.find("404")>=0:
111 return True110 return True
112 else:111 else:
113 return True112 return False
114113
115 def _dom_giver(self, url1, url2, context, vat):114 def _dom_giver(self, url1, url2, context, vat):
116 xml_data = self._load_url(3,url1 % vat)115 xml_data = self._load_url(3,url1 % vat)
117 if not self._eval_seniat_data(xml_data,context):116 if not self._eval_seniat_data(xml_data,vat,context):
118 dom = parseString(xml_data)117 dom = parseString(xml_data)
119 return self._parse_dom(dom, vat, url2)118 return self._parse_dom(dom, vat, url2)
120 else:119 else:
@@ -125,7 +124,7 @@
125 rp_obj.write(cr, uid, id, {'seniat_updated': True})124 rp_obj.write(cr, uid, id, {'seniat_updated': True})
126125
127 def update_rif(self, cr, uid, ids, context={}):126 def update_rif(self, cr, uid, ids, context={}):
128 aux=0127 aux=[]
129 rp_obj = self.pool.get('res.partner')128 rp_obj = self.pool.get('res.partner')
130 url_obj = self.browse(cr, uid, self.search(cr, uid, []))[0]129 url_obj = self.browse(cr, uid, self.search(cr, uid, []))[0]
131 url1 = url_obj.name + '%s'130 url1 = url_obj.name + '%s'
@@ -137,15 +136,14 @@
137 return res136 return res
138 else:137 else:
139 return False138 return False
139
140 for partner in rp_obj.browse(cr,uid,ids):140 for partner in rp_obj.browse(cr,uid,ids):
141 aux+=1
142 if partner.vat:141 if partner.vat:
143 vat_country, vat_number = rp_obj._split_vat(partner.vat)142 vat_country, vat_number = rp_obj._split_vat(partner.vat)
144 if vat_country.upper() == 'VE':143 if vat_country.upper() == 'VE':
145 print 'partner.vat[2:]',partner.vat[2:]
146 if len(partner.vat[2:])==10:144 if len(partner.vat[2:])==10:
147 xml_data = self._load_url(3,url1 %partner.vat[2:])145 xml_data = self._load_url(3,url1 %partner.vat[2:])
148 if not self._eval_seniat_data(xml_data,context):146 if not self._eval_seniat_data(xml_data,partner.vat[2:],context):
149 dom = parseString(xml_data)147 dom = parseString(xml_data)
150 res = rp_obj.write(cr,uid,partner.id,self._parse_dom(dom,partner.vat[2:],url2))148 res = rp_obj.write(cr,uid,partner.id,self._parse_dom(dom,partner.vat[2:],url2))
151 if res:149 if res:
152150
=== modified file 'l10n_ve_fiscal_requirements/wizard/update_info_partner.py'
--- l10n_ve_fiscal_requirements/wizard/update_info_partner.py 2012-01-19 01:37:26 +0000
+++ l10n_ve_fiscal_requirements/wizard/update_info_partner.py 2012-02-14 14:26:29 +0000
@@ -31,9 +31,15 @@
31 _name = 'update.info.partner'31 _name = 'update.info.partner'
32 32
33 def update_info(self, cr, uid, ids, context={}):33 def update_info(self, cr, uid, ids, context={}):
34 aux=[]
34 res_part_obj = self.pool.get('res.partner')35 res_part_obj = self.pool.get('res.partner')
35 seniat_url_obj = self.pool.get('seniat.url')36 seniat_url_obj = self.pool.get('seniat.url')
36 es_partner_ids= res_part_obj.search(cr, uid, [])37 sql= '''SELECT vat FROM res_partner GROUP BY vat HAVING count(vat) > 1 ;'''
38 cr.execute(sql)
39 record = cr.dictfetchall()
40 for r in record:
41 aux.append(r.values()[0])
42 es_partner_ids= res_part_obj.search(cr, uid, [('vat','not in',aux)])
37 seniat_url_obj.connect_seniat(cr, uid, es_partner_ids, context,True)43 seniat_url_obj.connect_seniat(cr, uid, es_partner_ids, context,True)
38 return{}44 return{}
3945
4046
=== modified file 'l10n_ve_topology/module/sector.py'
--- l10n_ve_topology/module/sector.py 2012-01-31 16:19:58 +0000
+++ l10n_ve_topology/module/sector.py 2012-02-14 14:26:29 +0000
@@ -64,7 +64,7 @@
64 'parish_id':fields.many2one('res.parish','Parish',help="In this field you enter the parish to which the sector is associated",domain= "[('municipalities_id','=',municipality_id)]" ),64 'parish_id':fields.many2one('res.parish','Parish',help="In this field you enter the parish to which the sector is associated",domain= "[('municipalities_id','=',municipality_id)]" ),
65 'zipcode_id':fields.many2one('res.zipcode',string='Zip Code',help="in this field is selected Zip Code associated with this sector"),65 'zipcode_id':fields.many2one('res.zipcode',string='Zip Code',help="in this field is selected Zip Code associated with this sector"),
66 'sector_id':fields.many2one('res.sector',string='Sector',required=False,help="in this field select the Sector associated with this Municipality"),66 'sector_id':fields.many2one('res.sector',string='Sector',required=False,help="in this field select the Sector associated with this Municipality"),
67 'city_id':fields.many2one('res.city',string='City',help="in this field select the city associated with this State"),67 'city_id':fields.many2one('res.city',string='City',domain= "[('state_id','=',state_id)]",help="in this field select the city associated with this State"),
68 'city':fields.function(_get_city_name, method=True, type='char', string='City', size=256, domain= "[('state_id','=',state_id)]",store=True),68 'city':fields.function(_get_city_name, method=True, type='char', string='City', size=256, domain= "[('state_id','=',state_id)]",store=True),
69 }69 }
7070