Skip to Content
Меню
Чтобы взаимодействовать с сообществом, необходимо зарегистрироваться.
Этот вопрос был отмечен
1 Ответить
2926 Представления

I need to change size of logo on invoice header only. At first attempt I tried this for selected layout:

< template id ="external_layout_bold_ksp" inherit_id ="web.external_layout_bold" > 

< xpath expr ="//div[@t-attf-class='header o_company_#{company.id}_layout']/div/div/div/ img"
position ="replace" >
< img t-if ="company.logo" style ="max-width: 350px;max-height: 190px;"
t-att-src ="image_data_uri(company.logo)" alt ="Logo" />

</ xpath >

 template >


it worked but it is changing all logos of all pdf reports for bold layout, but I need to resize only invoice report's logo

Аватар
Отменить
Лучший ответ

Hi, I have applied something like that in Odoo 11 and I think it will work on other versions.

To resize the logo in invoice report only, you need to pass value through context from invoice report and then check it in the external layout bold template.

I have added change_logo_size Boolean context value from invoice report and set it to true as below:

<template id="report_invoice_document_logo" inherit_id="account.report_invoice_document">
<xpath expr="//t[@t-call='web.external_layout']" position="before">
<t t-set="o" t-value="o.with_context(change_logo_size= True)"/>
</xpath>
</template>

Then in the inheritance of external layout bold, I have checked the value from the context and if it's true then apply the replace for image, otherwise leave it as its:

<template id="external_layout_bold_ksp" inherit_id="web.external_layout_bold">
<xpath expr="//div[@t-attf-class='header o_company_#{company.id}_layout']/div/div/div/img" position="replace">
<t t-if=" o and o.env and 'change_logo_size' in o.env.context and o.env.context.get('change_logo_size',False)">
<img t-if="company.logo" style="max-width: 350px;max-height: 190px;"
t-att-src="image_data_uri(company.logo)" alt="Logo"/>
</t>
<t t-else="">
<img t-if="company.logo" t-att-src="image_data_uri(company.logo)" alt="Logo"/>
</t>
</xpath>
</template>

Аватар
Отменить
Автор

Great, It worked in v15 and really liked your approach!

Great, thanks for feedback.

Related Posts Ответы Просмотры Активность
0
мая 22
1770
0
янв. 25
501
0
дек. 24
502
2
апр. 24
786
4
июл. 23
6451