Reviewers: ,


Please review this at http://codereview.tryton.org/171006/

Affected files:
  M trytond/report/report.py


Index: trytond/report/report.py
===================================================================
--- a/trytond/report/report.py
+++ b/trytond/report/report.py
@@ -165,7 +165,14 @@
                 pool.get('ir.translation'))
localcontext['setLang'] = lambda language: translate.set_language(language)

-        if not report.report_content:
+        report_content = report.report_content
+        if isinstance(report_content, buffer):
+            report_content = str(report_content)
+        style_content = report.style_content
+        if isinstance(style_content, buffer):
+            style_content = str(style_content)
+
+        if not report_content:
             raise Exception('Error', 'Missing report file!')

         fd, path = tempfile.mkstemp(
@@ -174,14 +181,14 @@
         outzip = zipfile.ZipFile(path, mode='w')

         content_io = StringIO.StringIO()
-        content_io.write(report.report_content)
+        content_io.write(report_content)
         content_z = zipfile.ZipFile(content_io, mode='r')

         style_info = None
         style_xml = None
         manifest = None
         for f in content_z.infolist():
-            if f.filename == 'styles.xml' and report.style_content:
+            if f.filename == 'styles.xml' and style_content:
                 style_info = f
                 style_xml = content_z.read(f.filename)
                 continue
@@ -190,13 +197,13 @@
                 continue
             outzip.writestr(f, content_z.read(f.filename))

-        if report.style_content:
+        if style_content:
             pictures = []

             #cStringIO difference:
#calling StringIO() with a string parameter creates a read-only object
             new_style_io = StringIO.StringIO()
-            new_style_io.write(report.style_content)
+            new_style_io.write(style_content)
             new_style_z = zipfile.ZipFile(new_style_io, mode='r')
             new_style_xml = new_style_z.read('styles.xml')
             for file in new_style_z.namelist():


--
tryton-dev@googlegroups.com mailing list

Reply via email to