Rifakat (OpenERP) has proposed merging
lp:~openerp-dev/openobject-server/6.0-opw-572488-rha into
lp:openobject-server/6.0.
Requested reviews:
Naresh(OpenERP) (nch-openerp)
Related bugs:
Bug #940263 in OpenERP Server: "[6.1] report engine generates inconsistent
odt/sxw files"
https://bugs.launchpad.net/openobject-server/+bug/940263
For more details, see:
https://code.launchpad.net/~openerp-dev/openobject-server/6.0-opw-572488-rha/+merge/98580
Hello,
Fix for duplication of the content of sxw report. When report type is sxw, it
duplicates contents in zip while writing using writestr().
To reproduce this,
1. Open any report from menu "Reports",(ex: Model Overview)
2. Set "Report Type" = sxw
3. Open this report
3. Save sxw and open saved sxw with archive editor to see multiple contents
into archive.
Created an empty zip file and write report contents after checking and avoid
duplication.
Please review it.
Regards,
Rifakat
--
https://code.launchpad.net/~openerp-dev/openobject-server/6.0-opw-572488-rha/+merge/98580
Your team OpenERP R&D Team is subscribed to branch
lp:~openerp-dev/openobject-server/6.0-opw-572488-rha.
=== modified file 'bin/report/report_sxw.py'
--- bin/report/report_sxw.py 2011-10-13 12:12:25 +0000
+++ bin/report/report_sxw.py 2012-03-21 06:31:21 +0000
@@ -586,10 +586,9 @@
create_doc = self.generators[mime_type]
odt = etree.tostring(create_doc(rml_dom, rml_parser.localcontext),
encoding='utf-8', xml_declaration=True)
- sxw_z = zipfile.ZipFile(sxw_io, mode='a')
- sxw_z.writestr('content.xml', odt)
- sxw_z.writestr('meta.xml', meta)
-
+
+ sxw_contents = {'content.xml':odt, 'meta.xml':meta, 'mimetype': mime_type}
+
if report_xml.header:
#Add corporate header/footer
rml_file = tools.file_open(os.path.join('base', 'report', 'corporate_%s_header.xml' % report_type))
@@ -607,11 +606,24 @@
rml_parser._add_header(odt)
odt = etree.tostring(odt, encoding='utf-8',
xml_declaration=True)
- sxw_z.writestr('styles.xml', odt)
+ sxw_contents['styles.xml'] = odt
finally:
rml_file.close()
+
+ #created empty zip writing sxw contents to avoid duplication
+ sxw_out = StringIO.StringIO()
+ sxw_z = zipfile.ZipFile(sxw_out, mode='w')
+
+ zin = zipfile.ZipFile (sxw_io, 'r')
+ for item in zin.infolist():
+ if item.filename not in sxw_contents.keys():
+ buffer = zin.read(item.filename)
+ sxw_z.writestr(item.filename, buffer)
+ for item, buffer in sxw_contents.iteritems():
+ sxw_z.writestr(item, buffer)
+
sxw_z.close()
- final_op = sxw_io.getvalue()
+ final_op = sxw_out.getvalue()
sxw_io.close()
return (final_op, mime_type)
_______________________________________________
Mailing list: https://launchpad.net/~openerp-dev-gtk
Post to : [email protected]
Unsubscribe : https://launchpad.net/~openerp-dev-gtk
More help : https://help.launchpad.net/ListHelp