Issues inserting image into report

Hi,

I am trying to insert an image from a record into a report. I have inserted a frame with the name: " image: bomitem.product.image, ‘image/jpg’ ". When trying to generate the report, I am getting the following stack trace:


Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/trytond/protocols/dispatcher.py", line 181, in _dispatch
    result = rpc.result(meth(*c_args, **c_kwargs))
  File "/usr/local/lib/python3.6/site-packages/trytond/report/report.py", line 204, in execute
    oext, content = cls._execute(records, data, action_report)
  File "/usr/local/lib/python3.6/site-packages/trytond/report/report.py", line 212, in _execute
    return cls.convert(action, cls.render(action, report_context))
  File "/usr/local/lib/python3.6/site-packages/trytond/report/report.py", line 314, in render
    data = rel_report(**report_context).render()
  File "/usr/local/lib/python3.6/site-packages/relatorio-0.9.1-py3.6.egg/relatorio/templates/base.py", line 35, in render
    self.events, method=method, encoding=encoding, out=out)
  File "/usr/local/lib/python3.6/site-packages/relatorio-0.9.1-py3.6.egg/relatorio/templates/opendocument.py", line 1169, in __call__
    self.xml_serializer(writer(stream)), encoding=encoding, out=writer)
  File "/usr/local/lib/python3.6/site-packages/Genshi-0.7.3-py3.6.egg/genshi/output.py", line 58, in encode
    for chunk in iterator:
  File "/usr/local/lib/python3.6/site-packages/Genshi-0.7.3-py3.6.egg/genshi/output.py", line 241, in __call__
    for kind, data, pos in stream:
  File "/usr/local/lib/python3.6/site-packages/Genshi-0.7.3-py3.6.egg/genshi/output.py", line 671, in __call__
    for kind, data, pos in stream:
  File "/usr/local/lib/python3.6/site-packages/Genshi-0.7.3-py3.6.egg/genshi/output.py", line 776, in __call__
    for kind, data, pos in chain(stream, [(None, None, None)]):
  File "/usr/local/lib/python3.6/site-packages/Genshi-0.7.3-py3.6.egg/genshi/output.py", line 596, in __call__
    for ev in stream:
  File "/usr/local/lib/python3.6/site-packages/relatorio-0.9.1-py3.6.egg/relatorio/templates/opendocument.py", line 1061, in __call__
    for kind, data, pos in stream:
  File "/usr/local/lib/python3.6/site-packages/Genshi-0.7.3-py3.6.egg/genshi/core.py", line 292, in _ensure
    for event in stream:
  File "/usr/local/lib/python3.6/site-packages/Genshi-0.7.3-py3.6.egg/genshi/filters/i18n.py", line 691, in __call__
    for kind, data, pos in stream:
  File "/usr/local/lib/python3.6/site-packages/Genshi-0.7.3-py3.6.egg/genshi/template/base.py", line 638, in _include
    for event in stream:
  File "/usr/local/lib/python3.6/site-packages/Genshi-0.7.3-py3.6.egg/genshi/template/markup.py", line 327, in _match
    for event in stream:
  File "/usr/local/lib/python3.6/site-packages/Genshi-0.7.3-py3.6.egg/genshi/template/base.py", line 578, in _flatten
    for kind, data, pos in stream:
  File "/usr/local/lib/python3.6/site-packages/Genshi-0.7.3-py3.6.egg/genshi/template/directives.py", line 168, in _generate
    attrs = _eval_expr(self.expr, ctxt, vars)
  File "/usr/local/lib/python3.6/site-packages/Genshi-0.7.3-py3.6.egg/genshi/template/base.py", line 289, in _eval_expr
    retval = expr.evaluate(ctxt)
  File "/usr/local/lib/python3.6/site-packages/Genshi-0.7.3-py3.6.egg/genshi/template/eval.py", line 178, in evaluate
    return eval(self.code, _globals, {'__data__': data})
  File "<string>", line 1, in <Expression "(lambda x, y: x.update(y) or x)(__relatorio_make_dimension(__relatorio_store_cache(140249608363848, bomitem.product.image, 'image/jpg'), '2cm', '') or {}, {'{urn:oasis:names:tc:opendocument:xmlns:drawing:1.0}name': (__relatorio_get_cache(140249608363848)[4:5] or [''])[0]} or {})">
TypeError: store() takes 3 positional arguments but 4 were given

Can anyone please advise on a potential solution to this issue? The image field is declared as follows:

image = fields.Binary('image')

Try with:
image: (bomitem.product.image, “image/jpg”)

1 Like

For the record, I created Bug 58: Ensure draw name is a tuple - Relatorio tracker which will prevent such mistake in the future.

Thanks for the help. Enclosing in brackets fixed the issue.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.