Skip to Content
Menu
This question has been flagged
2 Replies
4868 Views

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
Discard
Author

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
Discard
Related Posts Replies Views Activity
1
Nov 24
18021
1
Sep 23
1206
3
May 23
4095
7
Apr 23
47100
1
Dec 22
6438