Skip to Content
Menu
This question has been flagged
4 Replies
5744 Views

I'm trying to add an image to odoo invoices as the company sign to all pages in the report, i'am added it by this way 

<template id="durar_sale_order_sign_inv" inherit_id="account.report_invoice_document">
<xpath expr="//div[@id='qrcode']" position="after">
<div class="watermark" style="position:absolute;opacity:0.25;width:100%;heights:100%;z-index:4000;">
<img style="width:200px;heights:350px;text-align:right;border-radius: 50%;" t-attf-src="data:image/*;base64,{{o.sign_img}}"/>
</div>
</xpath>
</template>
it locates the image at the correct position I want, but it placed always in the last page 
 I need it on every page in the report , so I tried this way 

<template id="report_layout" inherit_id="web.external_layout_background">
<xpath
expr="//div[hasclass('header')]" position="inside">
<div
style="position:absolute;opacity:0.25;width:100%;heights:100%;z-index:4000;">
<img
style="width:200px;heights:opacity:0.25;350px;text-align:right;border-radius: 50%;" t-attf-src="data:image/*;base64,{{o.sign_img}}"/>
</div>
</xpath>
</template>

but this put the image under the header in every page and it covered contents, so how can I place the image in right bottom and repeat it in every page 
Avatar
Discard
Best Answer

Dear Mohamed Fouad,

Please try this code.

<xpath expr="//div[@class='clearfix']" position="replace">
                <div class="clearfix">
                        <div id="total" style="float:right;width:30%;">
                            <div>
                                <table class="table table-sm">
                                    <tr class="border-black o_subtotal" style="">
                                        <td><strong>Subtotal</strong></td>
                                        <td class="text-right">
                                            <span t-field="o.amount_untaxed"/>
                                        </td>
                                    </tr>
                                    <t t-foreach="o.amount_by_group" t-as="amount_by_group">
                                        <tr style="">
                                            <t t-if="len(o.tax_line_ids) == 1 and o.amount_untaxed == amount_by_group[2]">
                                                <td><span t-esc="amount_by_group[0]"/></td>
                                                <td class="text-right o_price_total">
                                                    <span t-esc="amount_by_group[3]" />
                                                </td>
                                            </t>
                                            <t t-else="">
                                                <td>
                                                    <span t-esc="amount_by_group[0]"/>
                                                    <span>&amp;nbsp;<span>on</span>
                                                        <t t-esc="amount_by_group[4]"/>
                                                    </span>
                                                </td>
                                                <td class="text-right o_price_total">
                                                    <span t-esc="amount_by_group[3]"/>
                                                </td>
                                            </t>
                                        </tr>
                                    </t>
                                    <tr class="border-black o_total">
                                        <td><strong>Total</strong></td>
                                        <td class="text-right">
                                            <span t-field="o.amount_total"/>
                                        </td>
                                    </tr>
                                </table>
                            </div>
                        </div>
                        <div>
                            <table>
                                <tr>
                                    <td>
                                       <span t-field="o.user_id.name"/>
                                    </td>
                                </tr>
                                <tr>
                                    <td>

<img t-if="o.user_id.user_signature" t-att-src="image_data_uri(o.user_id.user_signature)" style="max-height: 70px;" alt="Logo"/>

                                    </td>
                                </tr>
                            </table>
                        </div>
                    </div>
            </xpath>


Thank you,

Avatar
Discard
Author

in which template

<template id="inherit_report_invoice_document" inherit_id="account.report_invoice_document">

<!-- Insert your code ->

</template>

Best Answer

Hi,

I think you can add custom header or footer to achieve this. Because header/footer added from external_layout and it will display in all pages. Also one more idea to think, you can choose different report template in odoo. there is one template with background image. So we can check how it comes to all pages and this will give your answer

I hope this will helpful to you.

Thanks

Avatar
Discard
Best Answer

Try to give image path like that.

<img t-att-src="'/module_name/static/src/img/image_name.png'" />


Avatar
Discard
Author

the path is correct in my example and gives me the right image

Related Posts Replies Views Activity
1
Aug 23
2752
4
Jul 19
7096
0
Dec 18
2623
9
Feb 17
4829
0
Nov 24
90