Перейти к содержимому
Меню
Чтобы взаимодействовать с сообществом, необходимо зарегистрироваться.
Этот вопрос был отмечен
4 Ответы
7243 Представления

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

Related Posts Ответы Просмотры Активность
1
авг. 23
5223
4
июл. 19
8203
0
дек. 18
3581
9
февр. 17
5826
1
апр. 25
1188