c2c-oerpscenario team mailing list archive
-
c2c-oerpscenario team
-
Mailing list archive
-
Message #34533
[Bug 872521] Re: LocalService "create" method crashes when called with a txt report
M110412162-eyqmhncr
** Changed in: openobject-server
Status: New => Confirmed
** Changed in: openobject-server
Importance: Undecided => Medium
--
You received this bug notification because you are a member of C2C
OERPScenario, which is subscribed to OpenERP Project Group.
https://bugs.launchpad.net/bugs/872521
Title:
LocalService "create" method crashes when called with a txt report
Status in OpenERP Server:
Confirmed
Bug description:
Hi,
I've just updated OpenERP Client and OpenERP Server to revno 3518 and
some TXT reports begun to fail. It returns False when it creates the
service.
The error seems to be on server/bin/report/report_sxw.py. Checking on
that file with bzr log, we found out that on revno 3509 someone merged
a bug resolution with the comment owp 17683. When executed a bzr diff
between revnos 3508 and 3509, we saw the following diff:
<code>
1 === modified file 'bin/report/render/rml2pdf/trml2pdf.py'
2 --- bin/report/render/rml2pdf/trml2pdf.py 2011-05-04 09:50:00 +0000
3 +++ bin/report/render/rml2pdf/trml2pdf.py 2011-09-27 07:14:29 +0000
4 @@ -118,7 +118,7 @@
5 def draw(self):
6 self.canv.beginForm("pageCount")
7 self.canv.setFont("Helvetica", utils.unit_get(str(8)))
8 - self.canv.drawString(0, 0, str(self.canv.getPageNumber()))
9 + self.canv.drawString(0, 0, str(self.canv._pageCount))
10 self.canv.endForm()
11
12 class PageReset(platypus.Flowable):
13
14 === modified file 'bin/report/report_sxw.py'
15 --- bin/report/report_sxw.py 2011-06-27 10:25:37 +0000
16 +++ bin/report/report_sxw.py 2011-10-03 06:21:09 +0000
17 @@ -434,9 +434,9 @@
18 context={}
19 pool = pooler.get_pool(cr.dbname)
20 attach = report_xml.attachment
21 + results = []
22 if attach:
23 objs = self.getObjects(cr, uid, ids, context)
24 - results = []
25 for obj in objs:
26 aname = eval(attach, {'object':obj, 'time':time})
27 result = False
28 @@ -467,18 +467,24 @@
29 #TODO: should probably raise a proper osv_except instead, shouldn't we? see LP bug #325632
30 logging.getLogger('report').error('Could not create saved report attachment', exc_info=True)
31 results.append(result)
32 - if results:
33 - if results[0][1]=='pdf':
34 - from pyPdf import PdfFileWriter, PdfFileReader
35 - output = PdfFileWriter()
36 - for r in results:
37 - reader = PdfFileReader(cStringIO.StringIO(r[0]))
38 - for page in range(reader.getNumPages()):
39 - output.addPage(reader.getPage(page))
40 - s = cStringIO.StringIO()
41 - output.write(s)
42 - return s.getvalue(), results[0][1]
43 - return self.create_single_pdf(cr, uid, ids, data, report_xml, context)
44 + else:
45 + for id in ids:
46 + result = self.create_single_pdf(cr, uid, [id], data, report_xml, context)
47 + if not result:
48 + return False
49 + results.append(result)
50 + if results:
51 + if results[0][1] == 'pdf':
52 + from pyPdf import PdfFileWriter, PdfFileReader
53 + output = PdfFileWriter()
54 + for r in results:
55 + reader = PdfFileReader(cStringIO.StringIO(r[0]))
56 + for page in range(reader.getNumPages()):
57 + output.addPage(reader.getPage(page))
58 + s = cStringIO.StringIO()
59 + output.write(s)
60 + return s.getvalue(), results[0][1]
61 + return False
62
63 def create_single_pdf(self, cr, uid, ids, data, report_xml, context=None):
64 if not context:
65
</code>
If we see the difference between the added line on line 61 and the
removed line on line 43, it seems to be returning False when the
report type is not "pdf", which is contradictory because this chunk of
code is on method create_source_pdf(), which is called by method
create() if (and only if) the report_type is in ['pdf', 'raw', 'txt',
'html'], so, method create_single_pdf() (or some other on the calling
stack) should validate a txt report. Everything i'm talking about is
on class report_sxw, which is on the source file named above.
However, the solution should be just changing the "return False"
statement on line 61 for the return statement on line 43. I'm
proposing a patch to be evaluated. With this patch, everything should
be working again as pretty as always
Greets from Caracas - Venezuela
Israel Fermín Montilla.
To manage notifications about this bug go to:
https://bugs.launchpad.net/openobject-server/+bug/872521/+subscriptions
References