Merge lp:~vauxoo/openerp-mexico-localization/7.0_l10n_mx_ir_attachmnet_email_xml_sign_dev_jc into lp:openerp-mexico-localization/7.0

Proposed by Juan Carlos Hernandez
Status: Merged
Merged at revision: 331
Proposed branch: lp:~vauxoo/openerp-mexico-localization/7.0_l10n_mx_ir_attachmnet_email_xml_sign_dev_jc
Merge into: lp:openerp-mexico-localization/7.0
Diff against target: 108 lines (+49/-46)
1 file modified
l10n_mx_ir_attachment_facturae/ir_attachment_facturae.py (+49/-46)
To merge this branch: bzr merge lp:~vauxoo/openerp-mexico-localization/7.0_l10n_mx_ir_attachmnet_email_xml_sign_dev_jc
Reviewer Review Type Date Requested Status
Luis Torres - http://www.vauxoo.com (community) Needs Resubmitting
Juan Carlos Hernandez (community) Needs Resubmitting
Isaac López Zúñiga Needs Fixing
Moisés López - http://www.vauxoo.com Pending
Review via email: mp+195154@code.launchpad.net

Description of the change

se corrigió al enviar el xml,que enviará el xml firmado por correo

To post a comment you must log in.
Revision history for this message
Isaac López Zúñiga (isaako34) wrote :

Carlos.

Es importante validar si hay un id en el la variable attach_v3_2 antes de mandarla como parámetro en el write.

review: Needs Fixing
327. By Juan Carlos Hernandez

[IMP][l10n_mx_ir_attachment_facturae]add validation of variable

Revision history for this message
Juan Carlos Hernandez (openerp1) wrote :

Isaac.

Listo variable attach_v3_2 validado

review: Needs Resubmitting
328. By Luis Torres - http://www.vauxoo.com

[FIX][l10n_mx_ir_attachment_facturae]Change write by query, and change position in browse by for

Revision history for this message
Luis Torres - http://www.vauxoo.com (luis-cleto-) wrote :

Se cambio la manera de cambiar el resultado, para que no se adjunte el xml sin firmar

review: Needs Resubmitting

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'l10n_mx_ir_attachment_facturae/ir_attachment_facturae.py'
2--- l10n_mx_ir_attachment_facturae/ir_attachment_facturae.py 2013-11-13 00:00:34 +0000
3+++ l10n_mx_ir_attachment_facturae/ir_attachment_facturae.py 2013-11-15 21:11:27 +0000
4@@ -188,55 +188,58 @@
5 try:
6 if context is None:
7 context = {}
8+ invoice_obj = self.pool.get('account.invoice')
9+ attachment_obj = self.pool.get('ir.attachment')
10 attach = ''
11 index_xml = ''
12 msj = ''
13- invoice = self.browse(cr, uid, ids)[0].invoice_id
14- invoice_obj = self.pool.get('account.invoice')
15- attachment_obj = self.pool.get('ir.attachment')
16- type = self.browse(cr, uid, ids)[0].type
17- wf_service = netsvc.LocalService("workflow")
18- if 'cbb' in type:
19- msj = _("Signed")
20- if 'cfd' in type and not 'cfdi' in type:
21- attach = self.browse(cr, uid, ids)[0].file_input.id or False
22- index_xml = self.browse(cr, uid, ids)[
23- 0].file_xml_sign_index or False
24- msj = _("Attached Successfully XML CFD 2.2\n")
25- if 'cfdi' in type:
26- # upload file in custom module for pac
27- type__fc = self.get_driver_fc_sign()
28- if type in type__fc.keys():
29- fname_invoice = invoice.fname_invoice and invoice.fname_invoice + \
30- '.xml' or ''
31- fname, xml_data = invoice_obj._get_facturae_invoice_xml_data(
32- cr, uid, [invoice.id], context=context)
33- fdata = base64.encodestring(xml_data)
34- res = type__fc[type](
35- cr, uid, [ids[0]], fdata, context=context)
36- msj = tools.ustr(res.get('msg', False))
37- index_xml = res.get('cfdi_xml', False)
38- data_attach = {
39- 'name': fname_invoice,
40- 'datas': base64.encodestring(res.get('cfdi_xml', False)),
41- 'datas_fname': fname_invoice,
42- 'description': 'Factura-E XML CFD-I SIGN',
43- 'res_model': 'account.invoice',
44- #'res_id': invoice.id,
45- }
46- # Context, because use a variable type of our code but we
47- # dont need it.
48- attach = attachment_obj.create(
49- cr, uid, data_attach, context=None)
50- else:
51- msj += _("Unknow driver for %s" % (type))
52- self.write(cr, uid, ids,
53- {'file_xml_sign': attach or False,
54- 'last_date': time.strftime('%Y-%m-%d %H:%M:%S'),
55- 'msj': msj,
56- 'file_xml_sign_index': index_xml}, context=context)
57- wf_service.trg_validate(uid, self._name, ids[0], 'action_sign', cr)
58- return True
59+ for data in self.browse(cr, uid, ids, context=context):
60+ invoice = data.invoice_id
61+ type = data.type
62+ wf_service = netsvc.LocalService("workflow")
63+ attach_v3_2 = data.file_input and data.file_input.id or False
64+ if 'cbb' in type:
65+ msj = _("Signed")
66+ if 'cfd' in type and not 'cfdi' in type:
67+ attach = data.file_input and data.file_input.id or False
68+ index_xml = data.file_xml_sign_index or False
69+ msj = _("Attached Successfully XML CFD 2.2\n")
70+ if 'cfdi' in type:
71+ # upload file in custom module for pac
72+ type__fc = self.get_driver_fc_sign()
73+ if type in type__fc.keys():
74+ fname_invoice = invoice.fname_invoice and invoice.fname_invoice + \
75+ '.xml' or ''
76+ fname, xml_data = invoice_obj._get_facturae_invoice_xml_data(
77+ cr, uid, [invoice.id], context=context)
78+ fdata = base64.encodestring(xml_data)
79+ res = type__fc[type](cr, uid, [data.id], fdata, context=context)
80+ msj = tools.ustr(res.get('msg', False))
81+ index_xml = res.get('cfdi_xml', False)
82+ data_attach = {
83+ 'name': fname_invoice,
84+ 'datas': base64.encodestring(res.get('cfdi_xml', False)),
85+ 'datas_fname': fname_invoice,
86+ 'description': 'Factura-E XML CFD-I SIGN',
87+ 'res_model': 'account.invoice',
88+ 'res_id': invoice.id,
89+ }
90+ # Context, because use a variable type of our code but we
91+ # dont need it.
92+ attach = attachment_obj.create(cr, uid, data_attach, context=None)
93+ if attach_v3_2:
94+ cr.execute("""UPDATE ir_attachment
95+ SET res_id = Null
96+ WHERE id = %s""", (attach_v3_2,))
97+ else:
98+ msj += _("Unknow driver for %s" % (type))
99+ self.write(cr, uid, ids,
100+ {'file_xml_sign': attach or False,
101+ 'last_date': time.strftime('%Y-%m-%d %H:%M:%S'),
102+ 'msj': msj,
103+ 'file_xml_sign_index': index_xml}, context=context)
104+ wf_service.trg_validate(uid, self._name, data.id, 'action_sign', cr)
105+ return True
106 except Exception, e:
107 error = tools.ustr( traceback.format_exc() )
108 self.write(cr, uid, ids, {'msj': error}, context=context)