Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
3 Trả lời
692 Lượt xem

Hi there. I have this field in a list view. My goal is to have a fixed width for this column, so the image will not be cut if more fields are added to the list view.

<field name="image_1920" width="120px;" string="Image" widget="image" readonly="1" optional="show"/>

Now I am getting this error when opening the view: 

Odoo Client Error

UncaughtPromiseError > OwlError

Uncaught Promise > Invalid props for component 'ImageField': 'width' is not a number

Occured on localhost:8069 on 2025-08-02 15:36:41 GMT


Can anybody help? The weird thing is, it worked at first, but after a while I got the error. I removed it, changed it to the options attribute (works with resize, but gets cut off when more fields are added), then changed it back to width. Then it worked again for a while, now I get the error again. I have never seen such a behaviour.


Thank you.

Ảnh đại diện
Huỷ bỏ
Tác giả Câu trả lời hay nhất

Hi there, this does not work. I solved it using the options attribute, like this: 

<field name="image_1920" options="{'size': [0, 120]}"
Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

Hii,

in odoo owl the width parameter for an image field must be passed as a number , not as a css string like 120 px

here is example 

<tree>

​<field name="name"/>

​<field name="image_1920" width="120" string="Image" widget="image" />

</tree>


i hope it is usefull

Ảnh đại diện
Huỷ bỏ