跳至內容
選單
此問題已被標幟
4 回覆
7210 瀏覽次數

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 
頭像
捨棄
最佳答案

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,

頭像
捨棄
作者

in which template

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

<!-- Insert your code ->

</template>

最佳答案

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

頭像
捨棄
最佳答案

Try to give image path like that.

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


頭像
捨棄
作者

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

相關帖文 回覆 瀏覽次數 活動
1
8月 23
5184
4
7月 19
8176
0
12月 18
3560
9
2月 17
5803
1
4月 25
1138