Skip to Content
Menu
You need to be registered to interact with the community.
This question has been flagged
2 Odgovori
5417 Prikazi

How to display a default image (saved in /my_module/static/img/car1.png) in a form ?

I have a binary field like this:

car_image =field.Binary(string="car1",default=??)

in xml, i gave like this:

<field name="car_image1" widget="image"/>

Please help

Avatar
Opusti
Avtor

I added a default function like this:

But it says "Image cannot be displayed"

@api.model

def _get_default_image(self):

f = open('static/description/car1.png','rb')

self.car_image1 = base64.b64encode(f.read())

f.close()

car_image1 = fields.Binary(string="CAR Image", default='_get_default_image')

Best Answer

dear Rejini,

Check this link

Default Image

I hope I helped you...

Avatar
Opusti
Related Posts Odgovori Prikazi Aktivnost
1
nov. 24
19633
1
sep. 23
2502
3
maj 23
5187
7
apr. 23
48453
1
dec. 22
7399