İçereği Atla
Menü
Bu soru işaretlendi
1 Cevapla
5212 Görünümler

i want to show image from model res.company.plogo which is binary custom field

how can we do that like scr="res.company.plogo" or any other solution to get image from model res.company.plogo and show here down

<?xml version="1.0" encoding="UTF-8" ?>

<templates id="template" xml:space="preserve">

<t t-extend="Chrome">

<t t-jquery=".pos-logo" t-operation="replace">

<img src="" style="padding: 5px; margin: 0px; height: 40px; width: 100px;" />

</t>

</t>

</templates>

Avatar
Vazgeç
En İyi Yanıt

Hi,

You'll need to utilize Odoo's templating language and change the src attribute of the img tag to the base64 encoding of the binary data in order to display an image from a binary custom field in the res.company model. How to do it is as follows:

1. Initially, confirm that you have the res.company.plogo field is correctly defined as a binary custom field in the res.company model.

2. To acquire the binary data of the res.company.plogo field and transform it to a base64 string, you must next develop a new controller. The src attribute of the image tag will contain the base64 string.

3. You can alter your XML template as follows, presuming you have already developed the custom controller and saved the base64 string in a variable named plogo_base64:

<?xml version="1.0" encoding="UTF-8" ?>
<templates id="template" xml:space="preserve">
    <t t-extend="Chrome">
        <t t-jquery=".pos-logo" t-operation="replace">
<img t-att-src="'data:image/png;base64,' + plogo_base64" style="padding: 5px; margin: 0px; height: 40px; width: 100px;" />
        </t>
    </t>
</templates>


Hope it helps

Avatar
Vazgeç
İlgili Gönderiler Cevaplar Görünümler Aktivite
1
Oca 23
2539
0
Haz 21
2509
2
Haz 17
8799
3
Nis 17
5534
1
May 23
2784