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