【问题标题】:Odoo 10 - QWeb include barcode in reportOdoo 10 - QWeb 在报告中包含条形码
【发布时间】:2018-01-11 07:50:25
【问题描述】:

我正在尝试在报告中包含 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

【问题讨论】:

    标签: odoo-10 odoo


    【解决方案1】:

    你应该这样写:

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

    【讨论】:

    • 由于某种原因它不起作用。报告中不显示任何内容。我将尝试在较小的报告中隔离问题。
    【解决方案2】:

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

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

    【讨论】:

      【解决方案3】:

      你也可以试试这个:

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

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

      【讨论】:

        【解决方案4】:

        在 Q-web Report Include the Barcode 中,只在你的模块中包含图像,--->>> module_name-->>static-->>src-->>img--->> images .gif。

        代码:

        否则:

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

        希望它对你有用。

        【讨论】:

        【解决方案5】:

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

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

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多