Skip to Content
Menu
This question has been flagged
1 Reply
3516 Views

I want to make my image field height & weight constant.

Whenever I upload any image it should show with my given width & height.

I want to make width=250px & height=150px.

But not with css. i need to do it by coding in odoo.

If anyone are having some sort of knowledge about this..Please let me know about it

Avatar
Discard
Best Answer

Hi!

You can use the following code to resize image in your code (please adapt it as you need) :

from odoo import tools
@api.model
def create(self, vals):
tools.image_resize_images(vals, sizes={'image': (250, 150)})

Best regards!

Avatar
Discard