Skip ke Konten
Menu
Pertanyaan ini telah diberikan tanda
2 Replies
126 Tampilan

Hi where can i set the background image in the database so the line:

<t t-set="layout_background_url" t-value="'data:image/png;base64,%s' % company.layout_background_image.decode('utf-8') if company.layout_background_image and company.layout_background == 'Custom' else                 '/base/static/img/demo_logo_report.png' if company.layout_background == 'Demo logo' else ''"/>


       is working as expected, i use the  Enterprise version.


Avatar
Buang
Jawaban Terbai

Hi,


In Odoo, we can add a watermark/image/text in the report template.

We can add the image in the PDF report template as follows.


<template id="pdf_watermark_report"
inherit_id="web.external_layout_standard">
<xpath expr="//div[hasclass('row')][last()]" position="after">
<div class="row"
style="height:200px; width:300px;margin-left:30%;margin-top:50%;">
<div class="col-6" name="watermark">
<span t-attf-style="-webkit-transform:rotate(-{{company.rotating_angle}}deg);color:{{company.color_picker}};font-size:{{company.font_size}}px;text-align:center;position:absolute;text-align:center;opacity:0.25;">
<t t-if="company.watermark_type == 'text'">
<t t-esc="company.content_text"/>
</t>
<t t-if="company.watermark_type == 'image'">
<img t-if="company.background_image"
t-att-src="image_data_uri(company.background_image)"
style="position:absolute;height:200px; width:300px; opacity: 1;"/>
</t>
<t t-if="company.watermark_type == 'logo'">
<img t-if="company.logo"
t-att-src="image_data_uri(company.logo)"
style="position:absolute;height:200px; width:300px; opacity: 1;"/>
</t>
</span>
</div>
</div>
</xpath>
</template>


In this, the fields content_text, background_image, and logo are defined in the model 'res.company'. We then retrieve the picture that has been loaded into the report.

The kind can also be chosen using the 'watermak_type' option.

Our image can be positioned however we like by changing its width and height. 


You can also use the below App for this purpose.

https://apps.odoo.com/apps/modules/18.0/pdf_report_with_watermark


Hope it helps.

Avatar
Buang
Penulis Jawaban Terbai

i cann see it only in a part of the screen, but not in a full page


Avatar
Buang