Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
687 views
in Technique[技术] by (71.8m points)

pdf - How to display an image in a QWeb report?

I extended the 'report.external_layout_footer' qweb view to display image.

Below is my code in the file 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>

And here is my openerp.py content :

...
"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',],
...

But when I print a sale order, i can't view my image at the bottom of the page.

Does anyone have any suggestions?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...