ren*_*ard 1 pdf openerp odoo qweb
我将'report.external_layout_footer'qweb视图扩展为显示图像.
下面是我的文件reports/external_layout.xml中的代码:
<template id="report_footer_custom" inherit_id="report.external_layout_footer">
<xpath expr="//div[@class='footer']" position="replace">
<div class="footer">
<img t-att-src="'data:image/jpeg;base64,/var/www/cbl_openerp/openerp/cap_addons/cap_sale/img/footer.jpeg'"/>
<ul class="list-inline">
<li>Page:</li>
<li>
<span class="page"/>
</li>
<li>/</li>
<li>
<span class="topage"/>
</li>
</ul>
</div>
</xpath>
</template>
Run Code Online (Sandbox Code Playgroud)
这是我的openerp .py内容:
...
"depends": ["base","sale","report"],
...
"data": ['sale.xml',
'reports/reports.xml',
'reports/external_layout.xml',
'reports/informations_prestation.xml',
'views/product_template.xml',
'filter.xml'],
...
"images":['img/footer.jpeg',],
...
Run Code Online (Sandbox Code Playgroud)
但是当我打印销售订单时,我无法在页面底部查看我的图像.
有没有人有什么建议?
只需尝试以下代码并设置模块中的图像路径并运行它.
<template id="report_footer_custom"inherit_id="report.external_layout_footer">
<xpath expr="//div[@class='footer']" position="replace">
<div class="footer">
<img class="img img-responsive" src="/sale_order_report/static/src/img/header.jpg"/>
<ul class="list-inline">
<li>Page:</li>
<li><span class="page"/></li>
<li>/</li>
<li><span class="topage"/></li>
</ul>
</div>
</xpath>
</template>
Run Code Online (Sandbox Code Playgroud)
我方在QWeb报告自定义页脚中工作正常
如果您想使用非静态图像,可以按照以下步骤操作。
以公司标志为例:
<img
t-attf-src="data:image/*;base64,{{company.logo}}"
t-att-alt="company.name"
/>
Run Code Online (Sandbox Code Playgroud)
使用 mime 类型“image/*”将允许您使用不同格式的图像,而不仅仅是 jpeg 或 png。
然后,由于odoo默认将二进制数据渲染为base64,您可以简单地将图像的内容附加在base64,
.
归档时间: |
|
查看次数: |
14521 次 |
最近记录: |