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

Proposed by Luis Torres - http://www.vauxoo.com
Status: Needs review
Proposed branch: lp:~vauxoo/openerp-mexico-localization/7.0-l10n_mx_unification_create_report-dev_luis
Merge into: lp:openerp-mexico-localization/7.0
Diff against target: 207 lines (+77/-101)
3 files modified
l10n_mx_facturae/invoice.py (+26/-50)
l10n_mx_facturae_cbb/invoice.py (+31/-51)
l10n_mx_ir_attachment_facturae/invoice.py (+20/-0)
To merge this branch: bzr merge lp:~vauxoo/openerp-mexico-localization/7.0-l10n_mx_unification_create_report-dev_luis
Reviewer Review Type Date Requested Status
Isaac López Zúñiga Pending
Review via email: mp+193672@code.launchpad.net

Description of the change

Se unifico la función create_report y se removió la funcion create_report_pdf porque ya no se manda llamar

To post a comment you must log in.

Unmerged revisions

323. By Luis Torres - http://www.vauxoo.com

[IMP][l10n_mx_ir_attachment_facturae]Remove function create_report_pdf

322. By Luis Torres - http://www.vauxoo.com

[REF][l10n_mx_facturae]Unification of function create_report

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'l10n_mx_facturae/invoice.py'
2--- l10n_mx_facturae/invoice.py 2013-10-10 01:02:59 +0000
3+++ l10n_mx_facturae/invoice.py 2013-11-01 23:13:47 +0000
4@@ -118,56 +118,32 @@
5 class account_invoice(osv.Model):
6 _inherit = 'account.invoice'
7
8- def create_report(self, cr, uid, res_ids, report_name=False, file_name=False, context=None):
9- """
10- @param report_name : Name of report with the name of object more type
11- of report
12- @param file_name : Path where is save the report temporary more the
13- name of report that is 'openerp___facturae__' more six random
14- characters for no files duplicate
15- """
16- if context is None:
17- context = {}
18- if not report_name or not res_ids:
19- return (False, Exception('Report name and Resources ids are required !!!'))
20- # try:
21- ret_file_name = file_name+'.pdf'
22- service = netsvc.LocalService("report."+report_name)
23- (result, format) = service.create(cr, uid, res_ids, report_name, context=context)
24- fp = open(ret_file_name, 'wb+')
25- fp.write(result)
26- fp.close()
27- # except Exception,e:
28- # print 'Exception in create report:',e
29- # return (False,str(e))
30- return (True, ret_file_name)
31-
32- def create_report_pdf(self, cr, uid, ids, context={}):
33- if not context:
34- context = {}
35- id = ids[0]
36- (fileno, fname) = tempfile.mkstemp(
37- '.pdf', 'openerp_' + (False or '') + '__facturae__')
38- os.close(fileno)
39- file = self.create_report(cr, uid, [
40- id], "account.invoice.facturae.pdf", fname)
41- is_file = file[0]
42- fname = file[1]
43- if is_file and os.path.isfile(fname):
44- f = open(fname, "r")
45- data = f.read()
46- f.close()
47- data_attach = {
48- 'name': context.get('fname'),
49- 'datas': data and base64.encodestring(data) or None,
50- 'datas_fname': context.get('fname'),
51- 'description': 'Factura-E PDF',
52- 'res_model': self._name,
53- 'res_id': id,
54- }
55- self.pool.get('ir.attachment').create(
56- cr, uid, data_attach, context=context)
57- return True
58+ #~ def create_report_pdf(self, cr, uid, ids, context={}):
59+ #~ if not context:
60+ #~ context = {}
61+ #~ id = ids[0]
62+ #~ (fileno, fname) = tempfile.mkstemp(
63+ #~ '.pdf', 'openerp_' + (False or '') + '__facturae__')
64+ #~ os.close(fileno)
65+ #~ file = self.create_report(cr, uid, [
66+ #~ id], "account.invoice.facturae.pdf", fname)
67+ #~ is_file = file[0]
68+ #~ fname = file[1]
69+ #~ if is_file and os.path.isfile(fname):
70+ #~ f = open(fname, "r")
71+ #~ data = f.read()
72+ #~ f.close()
73+ #~ data_attach = {
74+ #~ 'name': context.get('fname'),
75+ #~ 'datas': data and base64.encodestring(data) or None,
76+ #~ 'datas_fname': context.get('fname'),
77+ #~ 'description': 'Factura-E PDF',
78+ #~ 'res_model': self._name,
79+ #~ 'res_id': id,
80+ #~ }
81+ #~ self.pool.get('ir.attachment').create(
82+ #~ cr, uid, data_attach, context=context)
83+ #~ return True
84
85 def action_make_cfd(self, cr, uid, ids, *args):
86 self._attach_invoice(cr, uid, ids)
87
88=== modified file 'l10n_mx_facturae_cbb/invoice.py'
89--- l10n_mx_facturae_cbb/invoice.py 2013-05-10 17:00:10 +0000
90+++ l10n_mx_facturae_cbb/invoice.py 2013-11-01 23:13:47 +0000
91@@ -87,57 +87,37 @@
92 #'date_invoice': lambda *a: time.strftime('%Y-%m-%d %H:%M:%S'),
93 }
94
95- def create_report(self, cr, uid, res_ids, report_name=False, file_name=False):
96- """
97- @param report_name : Name of report with the name of object more type
98- of report
99- @param file_name : Path where is save the report temporary more the
100- name of report that is 'openerp___facturae__' more six random
101- characters for no files duplicate
102- """
103- if not report_name or not res_ids:
104- return (False, Exception('Report name and Resources ids are required !!!'))
105- # try:
106- ret_file_name = file_name+'.pdf'
107- service = netsvc.LocalService("report."+report_name)
108- (result, format) = service.create(cr, uid, res_ids, {}, {})
109- fp = open(ret_file_name, 'wb+')
110- fp.write(result)
111- fp.close()
112- # except Exception,e:
113- # print 'Exception in create report:',e
114- # return (False,str(e))
115- return (True, ret_file_name)
116-
117- def create_report_pdf(self, cr, uid, ids, context={}):
118- if not context:
119- context = {}
120- id = ids[0]
121-
122- (fileno, fname) = tempfile.mkstemp(
123- '.pdf', 'openerp_' + (False or '') + '__facturae__')
124- os.close(fileno)
125-
126- file = self.create_report(cr, uid, [
127- id], "account.invoice.facturae.pdf2", fname)
128- is_file = file[0]
129- fname = file[1]
130- if is_file and os.path.isfile(fname):
131- f = open(fname, "r")
132- data = f.read()
133- f.close()
134-
135- data_attach = {
136- 'name': context.get('fname'),
137- 'datas': data and base64.encodestring(data) or None,
138- 'datas_fname': context.get('fname'),
139- 'description': u'Factura-E CBB PDF',
140- 'res_model': self._name,
141- 'res_id': id,
142- }
143- self.pool.get('ir.attachment').create(
144- cr, uid, data_attach, context=context)
145- return True
146+ #~ def create_report_pdf(self, cr, uid, ids, context={}):
147+ #~ if not context:
148+ #~ context = {}
149+ #~ id = ids[0]
150+#~
151+ #~ (fileno, fname) = tempfile.mkstemp(
152+ #~ '.pdf', 'openerp_' + (False or '') + '__facturae__')
153+ #~ os.close(fileno)
154+#~
155+ #~ file = self.create_report(cr, uid, [
156+ #~ id], "account.invoice.facturae.pdf2", fname)
157+ #~ is_file = file[0]
158+ #~ fname = file[1]
159+ #~ if is_file and os.path.isfile(fname):
160+ #~ f = open(fname, "r")
161+ #~ data = f.read()
162+ #~ f.close()
163+#~
164+ #~ data_attach = {
165+ #~ 'name': context.get('fname'),
166+ #~ 'datas': data and base64.encodestring(data) or None,
167+ #~ 'datas_fname': context.get('fname'),
168+ #~ 'description': u'Factura-E CBB PDF',
169+ #~ 'res_model': self._name,
170+ #~ 'res_id': id,
171+ #~ }
172+ #~ self.pool.get('ir.attachment').create(
173+ #~ cr, uid, data_attach, context=context)
174+ #~ return True
175+ #~
176+ #~
177
178 """def action_cancel_draft(self, cr, uid, ids, context=None):
179 attachment_obj = self.pool.get('ir.attachment')
180
181=== modified file 'l10n_mx_ir_attachment_facturae/invoice.py'
182--- l10n_mx_ir_attachment_facturae/invoice.py 2013-09-25 21:19:59 +0000
183+++ l10n_mx_ir_attachment_facturae/invoice.py 2013-11-01 23:13:47 +0000
184@@ -82,3 +82,23 @@
185 result['views'] = [(res and res[1] or False, 'form')]
186 return result
187 return True
188+
189+ def create_report(self, cr, uid, res_ids, report_name=False, file_name=False, context=None):
190+ """
191+ @param report_name : Name of report with the name of object more type
192+ of report
193+ @param file_name : Path where is save the report temporary more the
194+ name of report that is 'openerp___facturae__' more six random
195+ characters for no files duplicate
196+ """
197+ if not context:
198+ context = {}
199+ if not report_name or not res_ids:
200+ return (False, Exception('Report name and Resources ids are required !!!'))
201+ ret_file_name = file_name + '.pdf'
202+ service = netsvc.LocalService("report."+report_name)
203+ (result, format) = service.create(cr, uid, res_ids, report_name, context=context)
204+ fp = open(ret_file_name, 'wb+')
205+ fp.write(result)
206+ fp.close()
207+ return (True, ret_file_name)