Odoo 10 - QWeb在报告中包含条形码

时间:2018-01-11 07:50:26

标签: odoo-10 odoo

我正在尝试在报告中包含QR条形码。

这样做的:

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

在浏览器中生成有效的条形码。

但在QWeb PDF报告模板中使用:

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

不起作用:

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 个答案:

答案 0 :(得分:1)

您应该写如下:

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

答案 1 :(得分:1)

在条形码的QWeb报告中,您必须尝试此代码......

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

答案 2 :(得分:0)

你也可以试试这个:

<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"/>

定义您想要的高度和宽度。

答案 3 :(得分:0)

在Q-web报告中包含条形码,其中仅包含模块中的图像,---&gt;&gt;&gt; MODULE_NAME - &GT;&GT;静 - &GT;&GT; SRC - &GT;&GT; IMG&--- GT;&GT; images.gif。

代码:    

其他:

您也可以直接从报告中获取条形码。

希望它能为你效劳。

答案 4 :(得分:0)

将此添加到您的报告文件中。

this.loaderService.display(true);
//http call ends
this.loaderService.display(false);
相关问题