← Back to team overview

c2c-oerpscenario team mailing list archive

[Bug 719947] Re: Report crash with <image name="image_ref"/> tag

 

** Patch added: "report_crash_patch"
   https://bugs.launchpad.net/bugs/719947/+attachment/1853524/+files/report_crash_patch

-- 
You received this bug notification because you are a member of C2C
OERPScenario, which is subscribed to the OpenERP Project Group.
https://bugs.launchpad.net/bugs/719947

Title:
  Report crash with <image name="image_ref"/> tag

Status in OpenERP Server:
  New

Bug description:
  On server 6.0, revno 3342:

  If you have this kind of tag in a rml file:

  <images>
    <image name="test_image">iVBORw0KGgoA.....4035t7Em5s</image>
  </images>

  
  to define a constant image and call it later in your report via:

  <image name="test_image" width="2cm" height="1.5cm"/> for example

  the report crashes with:

  [2011-02-16 11:37:27,594][louboutin] ERROR:web-services:[01]: Exception: 'str' object has no attribute 'read'
  [2011-02-16 11:37:27,595][louboutin] ERROR:web-services:[02]: Traceback (most recent call last):
  [2011-02-16 11:37:27,595][louboutin] ERROR:web-services:[03]:   File "/home/xafer/openerp/6.0/server/bin/service/web_services.py", line 724, in go
  [2011-02-16 11:37:27,596][louboutin] ERROR:web-services:[04]:     (result, format) = obj.create(cr, uid, ids, datas, context)
  [2011-02-16 11:37:27,597][louboutin] ERROR:web-services:[05]:   File "/home/xafer/openerp/6.0/server/bin/report/report_sxw.py", line 428, in create
  [2011-02-16 11:37:27,599][louboutin] ERROR:web-services:[06]:     fnct_ret = fnct(cr, uid, ids, data, report_xml, context)
  [2011-02-16 11:37:27,599][louboutin] ERROR:web-services:[07]:   File "/home/xafer/openerp/6.0/server/bin/report/report_sxw.py", line 491, in create_source_pdf
  [2011-02-16 11:37:27,599][louboutin] ERROR:web-services:[08]:     return self.create_single_pdf(cr, uid, ids, data, report_xml, context)
  [2011-02-16 11:37:27,599][louboutin] ERROR:web-services:[09]:   File "/home/xafer/openerp/6.0/server/bin/report/report_sxw.py", line 513, in create_single_pdf
  [2011-02-16 11:37:27,600][louboutin] ERROR:web-services:[10]:     pdf = create_doc(etree.tostring(processed_rml),rml_parser.localcontext,logo,title.encode('utf8'))
  [2011-02-16 11:37:27,600][louboutin] ERROR:web-services:[11]:   File "/home/xafer/openerp/6.0/server/bin/report/interface.py", line 193, in create_pdf
  [2011-02-16 11:37:27,600][louboutin] ERROR:web-services:[12]:     obj.render()
  [2011-02-16 11:37:27,601][louboutin] ERROR:web-services:[13]:   File "/home/xafer/openerp/6.0/server/bin/report/render/render.py", line 63, in render
  [2011-02-16 11:37:27,601][louboutin] ERROR:web-services:[14]:     result = self._render()
  [2011-02-16 11:37:27,601][louboutin] ERROR:web-services:[15]:   File "/home/xafer/openerp/6.0/server/bin/report/render/rml.py", line 41, in _render
  [2011-02-16 11:37:27,602][louboutin] ERROR:web-services:[16]:     return rml2pdf.parseNode(self.rml, self.localcontext, images=self.bin_datas, path=self.path,title=self.title)
  [2011-02-16 11:37:27,602][louboutin] ERROR:web-services:[17]:   File "/home/xafer/openerp/6.0/server/bin/report/render/rml2pdf/trml2pdf.py", line 972, in parseNode
  [2011-02-16 11:37:27,602][louboutin] ERROR:web-services:[18]:     r.render(fp)
  [2011-02-16 11:37:27,603][louboutin] ERROR:web-services:[19]:   File "/home/xafer/openerp/6.0/server/bin/report/render/rml2pdf/trml2pdf.py", line 303, in render
  [2011-02-16 11:37:27,605][louboutin] ERROR:web-services:[20]:     pt_obj.render(el)
  [2011-02-16 11:37:27,605][louboutin] ERROR:web-services:[21]:   File "/home/xafer/openerp/6.0/server/bin/report/render/rml2pdf/trml2pdf.py", line 943, in render
  [2011-02-16 11:37:27,606][louboutin] ERROR:web-services:[22]:     fis += r.render(node_story)
  [2011-02-16 11:37:27,606][louboutin] ERROR:web-services:[23]:   File "/home/xafer/openerp/6.0/server/bin/report/render/rml2pdf/trml2pdf.py", line 862, in render
  [2011-02-16 11:37:27,606][louboutin] ERROR:web-services:[24]:     return process_story(node_story)
  [2011-02-16 11:37:27,606][louboutin] ERROR:web-services:[25]:   File "/home/xafer/openerp/6.0/server/bin/report/render/rml2pdf/trml2pdf.py", line 855, in process_story
  [2011-02-16 11:37:27,606][louboutin] ERROR:web-services:[26]:     flow = self._flowable(node)
  [2011-02-16 11:37:27,606][louboutin] ERROR:web-services:[27]:   File "/home/xafer/openerp/6.0/server/bin/report/render/rml2pdf/trml2pdf.py", line 793, in _flowable
  [2011-02-16 11:37:27,606][louboutin] ERROR:web-services:[28]:     image_data = self.doc.images[node.get('name')].read()
  [2011-02-16 11:37:27,607][louboutin] ERROR:web-services:[29]: AttributeError: 'str' object has no attribute 'read'

  indeed, self.doc.images contains a dictionnary strings defining the images:
  self.doc.images = {'test_image': '\x89PNG\r\n\x1a\n\x ..... \x00IEND\xaeB`\x82', 'logo': '\x89PNG\r\n\x1a\n\x00\x00\x00\rIHDR\x00 .... \x00\x00\x00\x00IEND\xaeB`\x82'}

  The 'logo' image is an image of the company logo defined automatically
  and both images are string which do not have the 'read' attribute
  which kind of proves that 'str' is the correct format expected in this
  dictionnary....

  I'm not sure why it's there but it's clearly not supposed to be there:
  just change this line (see patch)
  image_data = self.doc.images[node.get('name')].read()
  into
  image_data = self.doc.images[node.get('name')]





References