Merge lp:~vauxoo/openerp-venezuela-localization/miguel-retencion-iva into lp:~openerp-venezuela/openerp-venezuela-localization/6.0-trunk
- miguel-retencion-iva
- Merge into 6.0-trunk
Proposed by
Miguel Delgado (Vauxoo)
Status: | Merged |
---|---|
Merged at revision: | 396 |
Proposed branch: | lp:~vauxoo/openerp-venezuela-localization/miguel-retencion-iva |
Merge into: | lp:~openerp-venezuela/openerp-venezuela-localization/6.0-trunk |
Diff against target: |
760 lines (+647/-8) (has conflicts) 9 files modified
l10n_ve_withholding_iva/__init__.py (+2/-0) l10n_ve_withholding_iva/__openerp__.py (+10/-2) l10n_ve_withholding_iva/generate_txt.py (+263/-0) l10n_ve_withholding_iva/generate_txt_view.xml (+108/-0) l10n_ve_withholding_iva/partner.py (+8/-6) l10n_ve_withholding_iva/report/__init__.py (+30/-0) l10n_ve_withholding_iva/report/list_wh_iva.py (+54/-0) l10n_ve_withholding_iva/report/list_wh_iva_report.rml (+157/-0) l10n_ve_withholding_iva/txt_wh_report.xml (+15/-0) Text conflict in l10n_ve_withholding_iva/__openerp__.py |
To merge this branch: | bzr merge lp:~vauxoo/openerp-venezuela-localization/miguel-retencion-iva |
Related bugs: | |
Related blueprints: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Nhomar - Vauxoo | Pending | ||
Review via email: mp+77951@code.launchpad.net |
Commit message
Description of the change
add to the 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_withholding_iva/__init__.py' |
2 | --- l10n_ve_withholding_iva/__init__.py 2011-10-01 01:22:41 +0000 |
3 | +++ l10n_ve_withholding_iva/__init__.py 2011-10-03 14:54:19 +0000 |
4 | @@ -22,6 +22,8 @@ |
5 | import account |
6 | import invoice |
7 | import partner |
8 | +import generate_txt |
9 | +import report |
10 | import res_company |
11 | import installer |
12 | |
13 | |
14 | === modified file 'l10n_ve_withholding_iva/__openerp__.py' |
15 | --- l10n_ve_withholding_iva/__openerp__.py 2011-10-02 05:41:11 +0000 |
16 | +++ l10n_ve_withholding_iva/__openerp__.py 2011-10-03 14:54:19 +0000 |
17 | @@ -32,17 +32,25 @@ |
18 | 'init_xml': [], |
19 | "depends" : ["l10n_ve_withholding"], |
20 | 'update_xml': [ |
21 | + |
22 | 'security/wh_iva_security.xml', |
23 | 'security/ir.model.access.csv', |
24 | - 'res_company_view.xml', |
25 | + 'generate_txt_view.xml', |
26 | + 'txt_wh_report.xml', |
27 | + 'res_company_view.xml', |
28 | 'account_invoice_view.xml', |
29 | 'account_view.xml', |
30 | - 'partner_view.xml', |
31 | + 'partner_view.xml', |
32 | 'wh_iva_view.xml', |
33 | "data/l10n_ve_withholding_data.xml", |
34 | "wh_iva_workflow.xml", |
35 | +<<<<<<< TREE |
36 | "account_workflow.xml", |
37 | "l10n_ve_withholding_iva_installer.xml", |
38 | +======= |
39 | + "account_workflow.xml", |
40 | + |
41 | +>>>>>>> MERGE-SOURCE |
42 | ], |
43 | 'demo_xml': ["demo/l10n_ve_withholding_iva_demo.xml"], |
44 | 'test': [], |
45 | |
46 | === added file 'l10n_ve_withholding_iva/generate_txt.py' |
47 | --- l10n_ve_withholding_iva/generate_txt.py 1970-01-01 00:00:00 +0000 |
48 | +++ l10n_ve_withholding_iva/generate_txt.py 2011-10-03 14:54:19 +0000 |
49 | @@ -0,0 +1,263 @@ |
50 | +#!/usr/bin/python |
51 | +# -*- encoding: utf-8 -*- |
52 | +########################################################################### |
53 | +# Module Writen to OpenERP, Open Source Management Solution |
54 | +# Copyright (C) OpenERP Venezuela (<http://openerp.com.ve>). |
55 | +# All Rights Reserved |
56 | +###############Credits###################################################### |
57 | +# Coded by: Humberto Arocha <humberto@openerp.com.ve> |
58 | +# Maria Gabriela Quilarque <gabriela@openerp.com.ve> |
59 | +# Javier Duran <javier@nvauxoo.com> |
60 | +# Planified by: Nhomar Hernandez |
61 | +# Finance by: Helados Gilda, C.A. http://heladosgilda.com.ve |
62 | +# Audited by: Humberto Arocha humberto@openerp.com.ve |
63 | +############################################################################# |
64 | +# This program is free software: you can redistribute it and/or modify |
65 | +# it under the terms of the GNU General Public License as published by |
66 | +# the Free Software Foundation, either version 3 of the License, or |
67 | +# (at your option) any later version. |
68 | +# |
69 | +# This program is distributed in the hope that it will be useful, |
70 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
71 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
72 | +# GNU General Public License for more details. |
73 | +# |
74 | +# You should have received a copy of the GNU General Public License |
75 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. |
76 | +############################################################################## |
77 | +from osv import osv |
78 | +from osv import fields |
79 | +from tools.translate import _ |
80 | +from tools import config |
81 | +import time |
82 | +import datetime |
83 | +from xml.etree.ElementTree import Element, SubElement, ElementTree, tostring |
84 | +import sys |
85 | +import base64 |
86 | + |
87 | +class txt_iva(osv.osv): |
88 | + _name = "txt.iva" |
89 | + |
90 | + #~ def _get_amount_total(self,cr,uid,ids,name,args,context=None): |
91 | + #~ res = {} |
92 | + #~ for txt in self.browse(cr,uid,ids,context): |
93 | + #~ res[txt.id]=0.0 |
94 | + #~ for txt_line in txt.txt_ids: |
95 | + #~ res[txt.id] += txt_line.amount_withheld |
96 | + #~ |
97 | + #~ return res |
98 | + |
99 | + #~ def _get_amount_total_base(self,cr,uid,ids,name,args,context=None): |
100 | + #~ res = {} |
101 | + #~ for txt in self.browse(cr,uid,ids,context): |
102 | + #~ res[txt.id]= 0.0 |
103 | + #~ for txt_line in txt.txt_ids: |
104 | + #~ print 'result: ',res[txt.id] |
105 | + #~ print 'monto: ', txt_line.untaxed |
106 | + #~ res[txt.id] += txt_line.untaxed |
107 | + #~ |
108 | + #~ return res |
109 | + |
110 | + _columns = { |
111 | + 'company_id': fields.many2one('res.company', 'Compañía', required=True, readonly=True,states={'draft':[('readonly',False)]}), |
112 | + 'state': fields.selection([ |
113 | + ('draft','Draft'), |
114 | + ('confirmed', 'Confirmed'), |
115 | + ('done','Done'), |
116 | + ('cancel','Cancelled') |
117 | + ],'Estado', select=True, readonly=True, help="Estado del Comprobante"), |
118 | + 'fiscalyear_id': fields.many2one('account.fiscalyear', 'Año Fiscal', required=True,readonly=True,states={'draft':[('readonly',False)]}), |
119 | + 'period_id':fields.many2one('account.period','Periodo',required=True,readonly=True,states={'draft':[('readonly',False)]}, domain="[('fiscalyear_id','=',fiscalyear_id)]"), |
120 | + 'type':fields.boolean('Retención Proveedores?',required=True,states={'draft':[('readonly',False)]}, help="Seleccione el tipo de retencion a realizar"), |
121 | + 'date_start': fields.date('Fecha Inicio',required=True,states={'draft':[('readonly',False)]}, help="Fecha de Inicio del periodo"), |
122 | + 'date_end': fields.date('Fecha Fin', required=True,states={'draft':[('readonly',False)]}, help="Fecha de Fin del periodo"), |
123 | + 'type':fields.boolean('Retención Proveedores?',required=True,states={'draft':[('readonly',False)]}, help="Seleccione el tipo de retencion a realizar"), |
124 | + 'txt_ids':fields.one2many('txt.iva.line','txt_id',domain="[('txt_id','=',False)]", readonly=True,states={'draft':[('readonly',False)]}, help='Lineas del archivo txt exigido por el SENIAT, para retención del IVA'), |
125 | + #~ 'amount_total_ret':fields.function(_get_amount_total,method=True, digits=(16, 2), readonly=True, string=' Total Monto de Retencion', help="Monto Total Retenido"), |
126 | + #~ 'amount_total_base':fields.function(_get_amount_total_base,method=True, digits=(16, 2), readonly=True, string='Total Base Imponible', help="Total de la Base Imponible"), |
127 | + } |
128 | + _rec_rame = 'company_id' |
129 | + _defaults = { |
130 | + 'state': lambda *a: 'draft', |
131 | + 'company_id': lambda self, cr, uid, context: \ |
132 | + self.pool.get('res.users').browse(cr, uid, uid, |
133 | + context=context).company_id.id, |
134 | + 'type': lambda *a:'True', |
135 | + } |
136 | + |
137 | + def action_anular(self, cr, uid, ids, context={}): |
138 | + return self.write(cr, uid, ids, {'state':'draft'}) |
139 | + |
140 | + def action_confirm(self, cr, uid, ids, context={}): |
141 | + return self.write(cr, uid, ids, {'state':'confirmed'}) |
142 | + |
143 | + def action_generate_lines_txt(self,cr,uid,ids,context={}): |
144 | + voucher_obj = self.pool.get('account.wh.iva') |
145 | + txt_iva_obj = self.pool.get('txt.iva.line') |
146 | + |
147 | + voucher_ids='' |
148 | + txt_brw= self.browse(cr,uid,ids[0]) |
149 | + txt_ids = txt_iva_obj.search(cr,uid,[('txt_id','=',txt_brw.id)]) |
150 | + if txt_ids: |
151 | + txt_iva_obj.unlink(cr,uid,txt_ids) |
152 | + |
153 | + if txt_brw.type: |
154 | + voucher_ids = voucher_obj.search(cr,uid,[('date_ret','>=',txt_brw.date_start),('date_ret','<=',txt_brw.date_end),('period_id','=',txt_brw.period_id.id),('state','=','done'),('type','in',['in_invoice','in_refund'])]) |
155 | + else: |
156 | + voucher_ids = voucher_obj.search(cr,uid,[('date_ret','>=',txt_brw.date_start),('date_ret','<=',txt_brw.date_end),('period_id','=',txt_brw.period_id.id),('state','=','done'),('type','in',['out_invoice','out_refund'])]) |
157 | + |
158 | + for voucher in voucher_obj.browse(cr,uid,voucher_ids): |
159 | + |
160 | + for voucher_lines in voucher.retention_line: |
161 | + |
162 | + if voucher_lines.invoice_id.state in ['open','paid']: |
163 | + txt_iva_obj.create(cr,uid, |
164 | + {'partner_id':voucher.partner_id.id, |
165 | + 'voucher_id':voucher.id, |
166 | + 'invoice_id':voucher_lines.invoice_id.id, |
167 | + 'txt_id': txt_brw.id, |
168 | + 'untaxed': voucher_lines.base_ret, |
169 | + 'amount_withheld': voucher_lines.amount_tax_ret, |
170 | + }) |
171 | + return True |
172 | + |
173 | + def action_done(self, cr, uid, ids, context={}): |
174 | + root = self.generate_txt(cr,uid,ids) |
175 | + self._write_attachment(cr,uid,ids,root,context) |
176 | + self.write(cr, uid, ids, {'state':'done'}) |
177 | + return True |
178 | + |
179 | + def get_type_document(self,cr,uid,txt_line): |
180 | + type= '03' |
181 | + if txt_line.invoice_id.type in ['out_invoice','in_invoice']: |
182 | + type= '01' |
183 | + elif txt_line.invoice_id.type in ['out_invoice','in_invoice'] and txt_line.invoice_id.parent_id: |
184 | + type= '02' |
185 | + return type |
186 | + |
187 | + def get_document_affected(self,cr,uid,txt_line,context): |
188 | + number='0' |
189 | + if txt_line.invoice_id.type in ['in_invoice','in_refund'] and txt_line.invoice_id.parent_id: |
190 | + number = txt_line.invoice_id.parent_id.reference |
191 | + elif txt_line.invoice_id.parent_id: |
192 | + number = txt_line.invoice_id.parent_id.number |
193 | + return number |
194 | + |
195 | + def get_number(self,cr,uid,number,inv_type,long): |
196 | + if not number: |
197 | + return '0' |
198 | + result= '' |
199 | + for i in number: |
200 | + if inv_type=='vou_number' and i.isdigit(): |
201 | + if len(result)<long: |
202 | + result = i + result |
203 | + elif i.isalnum(): |
204 | + if len(result)<long: |
205 | + result = i + result |
206 | + return result[::-1].strip() |
207 | + |
208 | + def get_document_number(self,cr,uid,ids,txt_line,inv_type,context): |
209 | + number=0 |
210 | + if txt_line.invoice_id.type in ['in_invoice','in_refund']: |
211 | + if not txt_line.invoice_id.reference: |
212 | + raise osv.except_osv(_('Invalid action !'),_("Imposible realizar archivo txt, debido a que la factura no tiene numero de referencia libre!")) |
213 | + else: |
214 | + number = self.get_number(cr,uid,txt_line.invoice_id.reference.strip(),inv_type,20) |
215 | + elif txt_line.invoice_id.number: |
216 | + number = self.get_number(cr,uid,txt_line.invoice_id.number.strip(),inv_type,20) |
217 | + return number |
218 | + |
219 | + def get_amount_exempt_document(self,cr,uid,txt_line): |
220 | + tax = 0 |
221 | + amount_doc = 0 |
222 | + for tax_line in txt_line.invoice_id.tax_line: |
223 | + if 'SDCF' in tax_line.name: |
224 | + tax = tax_line.base + tax |
225 | + else: |
226 | + amount_doc = tax_line.base + amount_doc |
227 | + return (tax,amount_doc) |
228 | + |
229 | + def get_buyer_vendor(self,cr,uid,txt,txt_line): |
230 | + if txt_line.invoice_id.type in ['out_invoice','out_refund']: |
231 | + vendor = txt.company_id.partner_id.vat[2:] |
232 | + buyer = txt_line.partner_id.vat[2:] |
233 | + else: |
234 | + buyer = txt.company_id.partner_id.vat[2:] |
235 | + vendor = txt_line.partner_id.vat[2:] |
236 | + return (vendor,buyer) |
237 | + |
238 | + def get_alicuota(self,cr,uid,txt_line): |
239 | + list = [] |
240 | + for tax_line in txt_line.invoice_id.tax_line: |
241 | + if '12' in tax_line.name: |
242 | + list.append(12) |
243 | + if '8' in tax_line.name: |
244 | + list.append(8) |
245 | + if '22' in tax_line.name: |
246 | + list.append(22) |
247 | + if '0' in tax_line.name: |
248 | + list.append(0) |
249 | + return max(list) |
250 | + |
251 | + def generate_txt(self,cr,uid,ids,context=None): |
252 | + txt_string = '' |
253 | + for txt in self.browse(cr,uid,ids,context): |
254 | + vat = txt.company_id.partner_id.vat[2:] |
255 | + for txt_line in txt.txt_ids: |
256 | + |
257 | + vendor,buyer=self.get_buyer_vendor(cr,uid,txt,txt_line) |
258 | + period = txt.period_id.name.split('/') |
259 | + period2 = period[1]+period[0] |
260 | + |
261 | + operation_type = 'V' if txt_line.invoice_id.type in ['out_invoice','out_refund'] else 'C' |
262 | + document_type = self.get_type_document(cr,uid,txt_line) |
263 | + document_number=self.get_document_number(cr,uid,ids,txt_line,'inv_number',context) |
264 | + control_number = self.get_number(cr,uid,txt_line.invoice_id.nro_ctrl,'inv_ctrl',20) |
265 | + document_affected= self.get_document_affected(cr,uid,txt_line,context) |
266 | + voucher_number = self.get_number(cr,uid,txt_line.voucher_id.number,'vou_number',14) |
267 | + amount_exempt,amount_untaxed = self.get_amount_exempt_document(cr,uid,txt_line) |
268 | + alicuota = self.get_alicuota(cr,uid,txt_line) |
269 | + |
270 | + txt_string= txt_string + buyer +'\t'+period2.strip()+'\n' |
271 | + #~ +'\t'\ |
272 | + #~ +txt_line.invoice_id.date_invoice+'\t'+operation_type+'\t'+document_type+'\t'+vendor+'\t'\ |
273 | + #~ +document_number+'\t'+control_number+'\t'+str(round(txt_line.invoice_id.amount_total,2))+'\t'\ |
274 | + #~ +str(round(amount_untaxed,2))+'\t'\ |
275 | + #~ +str(round(txt_line.amount_withheld,2))+'\t'+document_affected+'\t'+voucher_number+'\t'\ |
276 | + #~ +str(round(amount_exempt,2))+'\t'+str(alicuota)+'\t'+'0'\ |
277 | + |
278 | + return txt_string |
279 | + |
280 | + def _write_attachment(self, cr,uid,ids,root,context): |
281 | + ''' |
282 | + Codificar el txt, para guardarlo en la bd y poder verlo en el cliente como attachment |
283 | + ''' |
284 | + fecha = time.strftime('%Y_%m_%d') |
285 | + name = 'IVA_' + fecha +'.'+ 'txt' |
286 | + self.pool.get('ir.attachment').create(cr, uid, { |
287 | + 'name': name, |
288 | + 'datas': base64.encodestring(root), |
289 | + 'datas_fname': name, |
290 | + 'res_model': 'txt.iva', |
291 | + 'res_id': ids[0], |
292 | + }, context=context |
293 | + ) |
294 | + cr.commit() |
295 | + |
296 | +txt_iva() |
297 | + |
298 | + |
299 | +class txt_iva_line(osv.osv): |
300 | + _name = "txt.iva.line" |
301 | + |
302 | + _columns = { |
303 | + 'partner_id':fields.many2one('res.partner','Comprador/Vendedor',help="Persona jurídica ó natural que genera la Factura, Nota de Crédito, Nota de Débito o Certificación (vendedor)"), |
304 | + 'invoice_id':fields.many2one('account.invoice','Factura/ND/NC',help="Fecha de la factura, Nota de Crédito, Nota de Débito o Certificación, Declaración de Importación"), |
305 | + 'voucher_id':fields.many2one('account.wh.iva','Comprobante de Retencion IVA',help="Comprobante de Retencion de Impuesto al Valor Agregado (IVA)"), |
306 | + 'amount_withheld':fields.float('Amount Withheld'), |
307 | + 'untaxed':fields.float('Untaxed'), |
308 | + 'txt_id':fields.many2one('txt.iva','Documento-Generar txt IVA'), |
309 | + } |
310 | + _rec_name = 'partner_id' |
311 | + |
312 | +txt_iva_line() |
313 | |
314 | === added file 'l10n_ve_withholding_iva/generate_txt_view.xml' |
315 | --- l10n_ve_withholding_iva/generate_txt_view.xml 1970-01-01 00:00:00 +0000 |
316 | +++ l10n_ve_withholding_iva/generate_txt_view.xml 2011-10-03 14:54:19 +0000 |
317 | @@ -0,0 +1,108 @@ |
318 | +<?xml version="1.0" encoding="utf-8"?> |
319 | +<openerp> |
320 | + <data> |
321 | + |
322 | + <!-- |
323 | + ===================================================== |
324 | + XML GENERATE |
325 | + ===================================================== |
326 | + --> |
327 | + |
328 | + <record id="view_generate_txt_iva_tree" model="ir.ui.view"> |
329 | + <field name="name">generate.txt.iva.tree</field> |
330 | + <field name="model">txt.iva</field> |
331 | + <field name="type">tree</field> |
332 | + <field name="arch" type="xml"> |
333 | + <tree string="Archivo TXT"> |
334 | + <field name="company_id"/> |
335 | + <field name="fiscalyear_id"/> |
336 | + <field name="period_id"/> |
337 | + <field name="type"/> |
338 | + </tree> |
339 | + </field> |
340 | + </record> |
341 | + |
342 | + <record id="view_generate_txt_iva_form" model="ir.ui.view"> |
343 | + <field name="name">generate.txt.iva.form</field> |
344 | + <field name="model">txt.iva</field> |
345 | + <field name="type">form</field> |
346 | + <field name="arch" type="xml"> |
347 | + <form string="Lineas de Retencion para TXT"> |
348 | + <group col="4" colspan="4"> |
349 | + <field name="company_id"/> |
350 | + <field name="type"/> |
351 | + </group> |
352 | + <newline/> |
353 | + <group col="4" colspan="4"> |
354 | + <field name="fiscalyear_id" /> |
355 | + <field name="period_id" /> |
356 | + </group> |
357 | + <newline/> |
358 | + <group col="4" colspan="4"> |
359 | + <field name="date_start"/> |
360 | + <field name="date_end"/> |
361 | + </group> |
362 | + <notebook colspan="4"> |
363 | + <page string="Lineas de Retencion"> |
364 | + <field name="txt_ids" nolabel="1" colspan='4' widget="one2many_list"> |
365 | + <tree string="Lineas del archivo TXT"> |
366 | + <field name="partner_id"/> |
367 | + <field name="invoice_id"/> |
368 | + <field name="voucher_id"/> |
369 | + <field name="untaxed"/> |
370 | + <field name="amount_withheld"/> |
371 | + </tree> |
372 | + </field> |
373 | + <group col="4" colspan="2"> |
374 | + <field name="state" select="2" colspan="4"/> |
375 | + <button name="action_generate_lines_txt" string="Generar Lineas TXT" states="draft" type="object" icon="gtk-go-forward" colspan="4"/> |
376 | + <button name="action_confirm" string="Confirmar" states="draft" type="object" icon="gtk-go-forward" colspan="4"/> |
377 | + <button name="action_done" string="Realizar TXT" states="confirmed" type="object" icon="gtk-ok"/> |
378 | + <button name="action_anular" string="Anular" states="confirmed,done" type="object" icon="gtk-cancel"/> |
379 | + </group> |
380 | +<!-- |
381 | + <group col="2" colspan="2"> |
382 | + <field name="amount_total_ret"/> |
383 | + <field name="amount_total_base"/> |
384 | + </group> |
385 | +--> |
386 | + </page> |
387 | + </notebook> |
388 | + </form> |
389 | + </field> |
390 | + </record> |
391 | + |
392 | + <record model="ir.actions.act_window" id="action_generate_text_iva"> |
393 | + <field name="name">Generate TXT</field> |
394 | + <field name="res_model">txt.iva</field> |
395 | + <field name="type">ir.actions.act_window</field> |
396 | + <field name="view_type">form</field> |
397 | + <field name="view_mode">tree,form</field> |
398 | + </record> |
399 | + |
400 | + <record model="ir.actions.act_window.view" id="action_generate_txt_iva_tree"> |
401 | + <field name="sequence" eval="10"/> |
402 | + <field name="view_mode">tree</field> |
403 | + <field name="view_id" ref="view_generate_txt_iva_tree"/> |
404 | + <field name="act_window_id" ref="action_generate_text_iva"/> |
405 | + </record> |
406 | + |
407 | + <record model="ir.actions.act_window.view" id="action_generate_txt_iva_form"> |
408 | + <field name="sequence" eval="20"/> |
409 | + <field name="view_mode">form</field> |
410 | + <field name="view_id" ref="view_generate_txt_iva_form"/> |
411 | + <field name="act_window_id" ref="action_generate_text_iva"/> |
412 | + </record> |
413 | + |
414 | + <menuitem name="Generar TXT" |
415 | + id="menu_action_generate_txt_iva" |
416 | + parent="l10n_ve_withholding.menu_wh_suppiler" |
417 | + action="action_generate_text_iva"/> |
418 | + |
419 | + </data> |
420 | +</openerp> |
421 | + |
422 | + |
423 | + |
424 | + |
425 | + |
426 | |
427 | === modified file 'l10n_ve_withholding_iva/partner.py' |
428 | --- l10n_ve_withholding_iva/partner.py 2011-09-28 03:57:04 +0000 |
429 | +++ l10n_ve_withholding_iva/partner.py 2011-10-03 14:54:19 +0000 |
430 | @@ -55,6 +55,7 @@ |
431 | } |
432 | |
433 | def _load_url(self,retries,url): |
434 | + print 'load' |
435 | str_error= '404 Not Found' |
436 | while retries > 0: |
437 | try: |
438 | @@ -69,12 +70,11 @@ |
439 | return str_error |
440 | |
441 | def _buscar_porcentaje(self,rif,url): |
442 | - ''' |
443 | - Search percent of withholding connecting to SENIAT |
444 | - ''' |
445 | context={} |
446 | + print"esta pasando por aqui" |
447 | html_data = self._load_url(3,url %rif) |
448 | html_data = unicode(html_data, 'ISO-8859-1').encode('utf-8') |
449 | + print "html_data",html_data |
450 | self._eval_seniat_data(html_data,context) |
451 | search_str='La condición de este contribuyente requiere la retención del ' |
452 | pos = html_data.find(search_str) |
453 | @@ -86,13 +86,13 @@ |
454 | return 0.0 |
455 | |
456 | def _parse_dom(self,dom,rif,url_seniat): |
457 | - ''' |
458 | - Parsing data from SENIAT |
459 | - ''' |
460 | + print 'entrando dom' |
461 | name = dom.childNodes[0].childNodes[0].firstChild.data |
462 | wh_agent = dom.childNodes[0].childNodes[1].firstChild.data.upper()=='SI' and True or False |
463 | vat_apply = dom.childNodes[0].childNodes[2].firstChild.data.upper()=='SI' and True or False |
464 | wh_rate = self._buscar_porcentaje(rif,url_seniat) |
465 | + print "wh_rate",wh_rate |
466 | + print 'nombre: ',name |
467 | return {'name':name, 'wh_iva_agent':wh_agent,'vat_subjected':vat_apply,'wh_iva_rate':wh_rate} |
468 | |
469 | def _print_error(self, error, msg): |
470 | @@ -113,11 +113,13 @@ |
471 | self._print_error(_('No Connection !'),_("Could not connect! Check the URL ")) |
472 | |
473 | def update_rif(self, cr, uid, ids, context={}): |
474 | + print 'entando update' |
475 | for partner in self.browse(cr,uid,ids): |
476 | url1=partner.company_id.url_seniat1_company+'%s' |
477 | url2=partner.company_id.url_seniat2_company+'%s' |
478 | xml_data = self._load_url(3,url1 %partner.vat[2:]) |
479 | self._eval_seniat_data(xml_data,context) |
480 | + print 'xml_data',xml_data |
481 | dom = parseString(xml_data) |
482 | self.write(cr,uid,partner.id,self._parse_dom(dom,partner.vat[2:],url2)) |
483 | return True |
484 | |
485 | === added directory 'l10n_ve_withholding_iva/report' |
486 | === added file 'l10n_ve_withholding_iva/report/__init__.py' |
487 | --- l10n_ve_withholding_iva/report/__init__.py 1970-01-01 00:00:00 +0000 |
488 | +++ l10n_ve_withholding_iva/report/__init__.py 2011-10-03 14:54:19 +0000 |
489 | @@ -0,0 +1,30 @@ |
490 | +#!/usr/bin/python |
491 | +# -*- encoding: utf-8 -*- |
492 | +########################################################################### |
493 | +# Module Writen to OpenERP, Open Source Management Solution |
494 | +# Copyright (C) OpenERP Venezuela (<http://openerp.com.ve>). |
495 | +# All Rights Reserved |
496 | +###############Credits###################################################### |
497 | +# Coded by: Humberto Arocha <humberto@openerp.com.ve> |
498 | +# Maria Gabriela Quilarque <gabriela@openerp.com.ve> |
499 | +# Javier Duran <javier@nvauxoo.com> |
500 | +# Planified by: Nhomar Hernandez |
501 | +# Finance by: Helados Gilda, C.A. http://heladosgilda.com.ve |
502 | +# Audited by: Humberto Arocha humberto@openerp.com.ve |
503 | +############################################################################# |
504 | +# This program is free software: you can redistribute it and/or modify |
505 | +# it under the terms of the GNU General Public License as published by |
506 | +# the Free Software Foundation, either version 3 of the License, or |
507 | +# (at your option) any later version. |
508 | +# |
509 | +# This program is distributed in the hope that it will be useful, |
510 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
511 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
512 | +# GNU General Public License for more details. |
513 | +# |
514 | +# You should have received a copy of the GNU General Public License |
515 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. |
516 | +############################################################################## |
517 | + |
518 | +import list_wh_iva |
519 | + |
520 | |
521 | === added file 'l10n_ve_withholding_iva/report/list_wh_iva.py' |
522 | --- l10n_ve_withholding_iva/report/list_wh_iva.py 1970-01-01 00:00:00 +0000 |
523 | +++ l10n_ve_withholding_iva/report/list_wh_iva.py 2011-10-03 14:54:19 +0000 |
524 | @@ -0,0 +1,54 @@ |
525 | +#!/usr/bin/python |
526 | +# -*- encoding: utf-8 -*- |
527 | +########################################################################### |
528 | +# Module Writen to OpenERP, Open Source Management Solution |
529 | +# Copyright (C) OpenERP Venezuela (<http://openerp.com.ve>). |
530 | +# All Rights Reserved |
531 | +###############Credits###################################################### |
532 | +# Coded by: Humberto Arocha <humberto@openerp.com.ve> |
533 | +# Maria Gabriela Quilarque <gabriela@openerp.com.ve> |
534 | +# Javier Duran <javier@nvauxoo.com> |
535 | +# Planified by: Nhomar Hernandez |
536 | +# Finance by: Helados Gilda, C.A. http://heladosgilda.com.ve |
537 | +# Audited by: Humberto Arocha humberto@openerp.com.ve |
538 | +############################################################################# |
539 | +# This program is free software: you can redistribute it and/or modify |
540 | +# it under the terms of the GNU General Public License as published by |
541 | +# the Free Software Foundation, either version 3 of the License, or |
542 | +# (at your option) any later version. |
543 | +# |
544 | +# This program is distributed in the hope that it will be useful, |
545 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
546 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
547 | +# GNU General Public License for more details. |
548 | +# |
549 | +# You should have received a copy of the GNU General Public License |
550 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. |
551 | +############################################################################## |
552 | + |
553 | +import time |
554 | +import pooler |
555 | +from report import report_sxw |
556 | +from tools.translate import _ |
557 | + |
558 | +class list_wh_iva(report_sxw.rml_parse): |
559 | + def __init__(self, cr, uid, name, context): |
560 | + super(list_wh_iva, self).__init__(cr, uid, name, context=context) |
561 | + self.localcontext.update({ |
562 | + 'get_type_doc': self._get_type_document, |
563 | + }) |
564 | + |
565 | + def _get_type_document(self,line): |
566 | + return self.pool.get('txt.iva').get_type_document(self.cr,self.uid,line) |
567 | + |
568 | + #~ def get_type_document(self,cr,uid,txt_line): |
569 | + |
570 | + |
571 | + |
572 | +report_sxw.report_sxw( |
573 | + 'report.list_report_wh_vat2', |
574 | + 'txt.iva', |
575 | + 'addons/l10n_ve_withholding_iva/report/list_wh_iva_report.rml', |
576 | + parser=list_wh_iva, |
577 | + header=False |
578 | +) |
579 | |
580 | === added file 'l10n_ve_withholding_iva/report/list_wh_iva_report.rml' |
581 | --- l10n_ve_withholding_iva/report/list_wh_iva_report.rml 1970-01-01 00:00:00 +0000 |
582 | +++ l10n_ve_withholding_iva/report/list_wh_iva_report.rml 2011-10-03 14:54:19 +0000 |
583 | @@ -0,0 +1,157 @@ |
584 | +<?xml version="1.0"?> |
585 | +<document filename="test.pdf"> |
586 | + <template pageSize="(280.0mm,210.0mm)" title="Test" author="Martin Simon" allowSplitting="20" showBoundary="0"> |
587 | + <pageTemplate id="first"> |
588 | + <pageGraphics> |
589 | + <image x="7.0mm" y="175.0mm" height="25mm" width="96mm">[[company.logo and company.logo or removeParentNode('image')]]</image> |
590 | + <drawString x="7.0mm" y="175.0mm">[[company.logo and removeParentNode('para') or company.name]]</drawString> |
591 | + <place x="7.0mm" y="100.0mm" width="280.0mm" height="100.0mm"> |
592 | + <!--TABLA DE TITULOS--> |
593 | + <blockTable colWidths="96mm,170mm" style="TITLE"> |
594 | + <tr> |
595 | + <td><para style="TITLE"></para> |
596 | + </td> |
597 | + <td> |
598 | + <para style="TITLE"><b>DECLARACION INFORMATIVA DE RETENCIONES IVA</b></para> |
599 | + </td> |
600 | + </tr> |
601 | + </blockTable> |
602 | + <blockTable colWidths="96mm,170.0mm" style="TITLEGRISCLAROARRIBA"> |
603 | + <tr> |
604 | + <td><para style="ITEMSCENTER"> </para> |
605 | + </td> |
606 | + <td> |
607 | + <para style="ITEMSCENTER"><b>PERIODO FISCAL</b></para> |
608 | + </td> |
609 | + </tr> |
610 | + </blockTable> |
611 | + <blockTable colWidths="96mm,170.0mm" style="TITLEGRISWHITE"> |
612 | + <tr> |
613 | + <td><para style="ITEMSCENTER"> </para> |
614 | + </td> |
615 | + <td> |
616 | + <para style="ITEMSCENTER"><b>[[ o.period_id.name]]</b></para> |
617 | + </td> |
618 | + </tr> |
619 | + </blockTable> |
620 | + </place> |
621 | + <setFont name="Helvetica-BoldOblique" size="8.0"/> |
622 | + <drawRightString x="270mm" y="5mm">RETENCIONES DE IVA / PAGINA: <pageNumber/> DE <pageCount/> </drawRightString> |
623 | + |
624 | + </pageGraphics> |
625 | + <frame id="first" x1="20.0" y1="20.0" width="753" height="480"/> |
626 | + </pageTemplate> |
627 | + </template> |
628 | + |
629 | + <stylesheet> |
630 | + <blockTableStyle id="TITLE"> |
631 | + <lineStyle kind="GRID" colorName="black" start="1,0" stop="-1,-1" thickness="0.5"/> |
632 | + <blockValign value="TOP"/> |
633 | + </blockTableStyle> |
634 | + <blockTableStyle id="TOTAL"> |
635 | + <blockValign value="TOP"/> |
636 | + <lineStyle kind="GRID" colorName="black" start="1,0" stop="-1,-1" thickness="0.5" /> |
637 | + </blockTableStyle> |
638 | + <blockTableStyle id="TITLEGRISCLAROARRIBA"> |
639 | + <blockBackground colorName="#e5e2e5" start="1,0" stop="-1,-1"/> |
640 | + <lineStyle kind="GRID" colorName="black" start="1,0" stop="-1,-1" thickness="0.5"/> |
641 | + <blockValign value="MIDDLE"/> |
642 | + </blockTableStyle> |
643 | + <blockTableStyle id="TITLEGRISWHITE"> |
644 | + <lineStyle kind="GRID" colorName="black" start="1,0" stop="-1,-1" thickness="0.5"/> |
645 | + <blockValign value="MIDDLE"/> |
646 | + </blockTableStyle> |
647 | + <blockTableStyle id="Tabla3"> |
648 | + <blockBackground colorName="#e5e2e5" start="0,0" stop="-1,0"/> |
649 | + <blockAlignment value="LEFT"/> |
650 | + <blockValign value="TOP"/> |
651 | + <lineStyle kind="GRID" colorName="black" start="0,0" stop="-1,-1" thickness="0.5"/> |
652 | + <blockValign value="MIDDLE"/> |
653 | + </blockTableStyle> |
654 | + <blockTableStyle id="Tablatotalgeneral"> |
655 | + <blockAlignment value="LEFT"/> |
656 | + <blockValign value="TOP"/> |
657 | + <lineStyle kind="GRID" colorName="black" start="9,0" stop="-1,-1" thickness="0.5"/> |
658 | + <blockValign value="MIDDLE"/> |
659 | + </blockTableStyle> |
660 | + <initialize> |
661 | + <paraStyle name="all" alignment="justify"/> |
662 | + </initialize> |
663 | + <paraStyle name="TITLE" alignment="CENTER" fontName="Helvetica" fontSize="12.0" leading="20" spaceBefore="-3.0" textColor="black"/> |
664 | + <paraStyle name="ITEMSCENTER" alignment="CENTER" fontName="Helvetica-Bold" fontSize="10.0" leading="9" spaceBefore="3.0" textColor="black"/> |
665 | + <paraStyle name="ITEMSRIF" alignment="CENTER" fontName="Helvetica-Bold" fontSize="12.0" leading="11" spaceBefore="3.0" textColor="black"/> |
666 | + <paraStyle name="P15" fontName="Helvetica-Bold" fontSize="10.0" leading="10" spaceBefore="3.0" alignment="CENTER"/> |
667 | + <paraStyle name="P12" fontName="Helvetica" fontSize="10.0" leading="11" alignment="CENTER"/> |
668 | + <paraStyle name="P13" fontName="Helvetica" fontSize="10.0" leading="11" alignment="RIGHT"/> |
669 | + <paraStyle name="P16" fontName="Helvetica-Bold" fontSize="10.0" leading="11" alignment="RIGHT"/> |
670 | + <paraStyle name="P14" fontName="Helvetica" fontSize="10.0" leading="11" alignment="LEFT"/> |
671 | + <paraStyle name="P22" fontName="Helvetica" fontSize="9.0" leading="11" spaceBefore="0.0" spaceAfter="6.0" alignment="RIGHT"/> |
672 | + </stylesheet> |
673 | + <images/> |
674 | + |
675 | + <story> |
676 | + <para>[[repeatIn(objects,'o')]]</para> |
677 | + <para>[[ setLang(company.partner_id.lang) ]]</para> |
678 | + <blockTable colWidths="410.0,198.0,50.0,50.0,45.0" repeatRows='1' style="Tabla3"> |
679 | +<!-- |
680 | + <blockTable colWidths="75.0,335.0,68.0,50.0,80.0,60.0,85.0" repeatRows='1' style="Tabla3"> |
681 | +--> |
682 | + <tr> |
683 | + <td><para style="P15">RIF Contribuyente</para></td> |
684 | + <td><para style="P15">Periodo</para></td> |
685 | + <td><para style="P15">Fecha Doc.</para></td> |
686 | + <td><para style="P15">Tipo Ope.</para></td> |
687 | + <td><para style="P15">Tipo Doc.</para></td> |
688 | +<!-- |
689 | + <td><para style="P15">RIF C/V</para></td> |
690 | + <td><para style="P15">Num Doc.</para></td> |
691 | + <td><para style="P15">Num Control</para></td> |
692 | + <td><para style="P15">Monto Doc.</para></td> |
693 | + <td><para style="P15">Base Impo.</para></td> |
694 | + <td><para style="P15">Monto IVA</para></td> |
695 | + <td><para style="P15">Num.Doc.Afec.</para></td> |
696 | + <td><para style="P15">Num.Compro.</para></td> |
697 | + <td><para style="P15">Monto Exc. IVA</para></td> |
698 | + <td><para style="P15">Alicuota</para></td> |
699 | + <td><para style="P15">Expediente</para></td> |
700 | +--> |
701 | + </tr> |
702 | + <tr>[[repeatIn(o.txt_ids,'line')]] |
703 | + <td><para style="P12">[[ '98798' ]]</para></td> |
704 | + <td><para style="P14">[[ o.period_id.name ]]</para></td> |
705 | + <td><para style="P12">[[ line.invoice_id.date_invoice ]]</para></td> |
706 | + <td><para style="P12">[[ (line.invoice_id.type in ['out_invoice','out_refund']) and 'V' or 'C' ]]</para></td> |
707 | + <td><para style="P13">[[ get_type_doc(line) ]]</para></td> |
708 | + |
709 | +<!-- |
710 | + <td><para style="P13">[[ ]]</para></td> |
711 | + <td><para style="P13">[[ ]]</para></td> |
712 | + <td><para style="P13">[[ ]]</para></td> |
713 | + <td><para style="P13">[[ ]]</para></td> |
714 | + <td><para style="P13">[[ ]]</para></td> |
715 | + <td><para style="P13">[[ ]]</para></td> |
716 | + <td><para style="P13">[[ ]]</para></td> |
717 | + <td><para style="P13">[[ ]]</para></td> |
718 | + <td><para style="P13">[[ ]]</para></td> |
719 | + <td><para style="P13">[[ ]]</para></td> |
720 | + <td><para style="P13">[[ ]]</para></td> |
721 | +--> |
722 | + </tr> |
723 | + </blockTable> |
724 | + <blockTable colWidths="410.0,198.0,145.0" style="TOTAL"> |
725 | + <tr> |
726 | + <td><para style="P22"><font color="white"></font></para></td> |
727 | + <td><para style="P16">TOTAL BASE IMPONIBLE</para></td> |
728 | + <td><para style="P16">[[ formatLang(o.amount_total_base) ]]</para></td> |
729 | + </tr> |
730 | + <tr> |
731 | + <td><para style="P22"><font color="white"></font></para></td> |
732 | + <td><para style="P16">TOTAL MONTO DE RETENCION</para></td> |
733 | + <td><para style="P16">[[ formatLang(o.amount_total_ret) ]]</para></td> |
734 | + </tr> |
735 | + </blockTable> |
736 | + |
737 | + </story> |
738 | + |
739 | +</document> |
740 | + |
741 | |
742 | === added file 'l10n_ve_withholding_iva/txt_wh_report.xml' |
743 | --- l10n_ve_withholding_iva/txt_wh_report.xml 1970-01-01 00:00:00 +0000 |
744 | +++ l10n_ve_withholding_iva/txt_wh_report.xml 2011-10-03 14:54:19 +0000 |
745 | @@ -0,0 +1,15 @@ |
746 | +<?xml version="1.0" encoding="utf-8"?> |
747 | +<openerp> |
748 | + <data> |
749 | + <report |
750 | + id="list_report_wh_vat" |
751 | + menu="True" |
752 | + model="txt.iva" |
753 | + name="list_report_wh_vat2" |
754 | + rml="l10n_ve_withholding_iva/report/list_wh_iva_report.rml" |
755 | + string="Retenciones IVA" |
756 | + auto = "True" |
757 | + header="False"/> |
758 | + </data> |
759 | +</openerp> |
760 | + |