2
votes

I am trying to include a QR barcode in a report.

Doing:

https://www.foo.com/report/barcode/QR/test 

Generates a valid barcode in the browser.

But using in a QWeb PDF report template:

<img t-att-src="/report/barcode/QR/test"/>

Does not work:

File "/usr/lib/python2.7/dist-packages/odoo/addons/base/ir/ir_qweb/ir_qweb.py", line 300, in _compile_expr
  st = ast.parse(expr.strip(), mode='eval')
File "/usr/lib/python2.7/ast.py", line 37, in parse
  return compile(source, filename, mode, PyCF_ONLY_AST)
File "<unknown>", line 1
  /report/barcode/QR/test
  ^
SyntaxError: invalid syntax
5

5 Answers

1
votes

You should write as following :

<img t-att-src="'/report/barcode/QR/test'"/>
1
votes

In QWeb reports for barcode you have to try this code...

<img t-if="o.barcode" t-att-src="'data:image/png;base64,%s' % o.barcode"/>
0
votes

Also you can try this :

<img t-att-src="'/report/barcode/QR/test? 
 type=%s&value=%s&width=%s&height=%s' % ('EAN13', o.ean13, 600, 900)" 
 style="width:100%;height:100px"/>

Define height and width that you want.

0
votes

In Q-web Report Include the Barcode, that have only include the image in your module,--->>> module_name-->>static-->>src-->>img--->> images.gif.

Code :

Else :

You can directly get the barcode from the report also.

Hope It will Work for you.

0
votes

Add this to your report file.

<center style="margin:6px 0;">
   <img t-if="o.barcode" t-att-src="'/report/barcode/?type=%s&amp;value=%s&amp;width=%s&amp;height=%s' %('Code128',o.barcode,250,50)"/>
</center>