Přejít na obsah
Menu
You need to be registered to interact with the community.
This question has been flagged
1 Odpovědět
5219 Zobrazení

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
Zrušit
Nejlepší odpověď

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
Zrušit
Related Posts Odpovědi Zobrazení Aktivita
1
led 23
2540
0
čvn 21
2510
2
čvn 17
8799
3
dub 17
5536
1
kvě 23
2787