How to display an image in a QWeb report?

£可爱£侵袭症+ 提交于 2019-11-28 11:48:40
DASADIYA CHAITANYA

Just try this below code and set the image path from your module and run it .

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

My side its working fine in the QWeb Report Custom Footer

In case you want to use an image that isn't static, here's what you can do instead.

Using the company logo as an example:

<img
  t-attf-src="data:image/*;base64,{{company.logo}}"
  t-att-alt="company.name"
  />

Using the mime type "image/*" will let you use different format of image and not just jpeg or just png.

Then as odoo render by default binary data as base64, you can simply append the content of the image after base64,.

The following snippet also works for QWeb reports (Odoo v10).

<span t-field="o.product_id.image_medium" t-field-options="{'widget': 'image'}"/>

...where o.product_id.image_medium is a dynamic field.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!