Help

欢迎!

该社区面向专业人士和我们产品和服务的爱好者。
分享和讨论最好的内容和新的营销理念,建立您的专业形象,一起成为更好的营销人员。


0

Changing column widths tree view

Avatar
odoo
Avatar
Discard
8 Answers
0
Avatar
odoo
Best Answer

Use group tag with colspan attribute around your fields.

Avatar
Discard
0
Avatar
odoo
Best Answer

I can use it in odoo9. I also use min-width to limit the minimum size of the width.

.my_class [data-id="apply_subject"] {

width:330px !important;

min-width: 130px !important;

}
Avatar
Discard
0
Avatar
odoo
Best Answer

Hi,

I was facing this problem and I finally found the solution to customize a column in TREE view, only for ONE view ;

Solution 1 that doesn't work :

  • xml <field width="200" /> or <field style="width: 200" /> or <field style="width: 30 %%" />

--> width attribute doesn't seem to work in tree view ;

Solution 2 that doesn't work :

  • xml <field class="my_class" /> ;
  • css .my_class { width: 1000px;}

--> class attribute doesn't seem to work in tree view ;

Solution 3 that doesn't work :

  • xml : <field name="my_field" />
  • css : [data-id="my_field"]{width: 1000px;}

--> this works for ALL the column named "my_field". Not very good if we want to change the render of a column if the field is "name" ;

The workaround I found

  • xml : <tree string="Tree String" version="7.0" class="my_class"> <field name="my_field" />
  • css : .my_class [data-id="my_field"]{width: 1000px;}

--> class attribute works on tree tag.

-->To be sure to target only the desired view the name of my class is "myModuleName__myTreeViewName"

Thanks for your feedback.

6 Comments
Avatar
Discard
Avatar
odoo
-

Works perfectly, thanks!

Avatar
odoo
-

works great for setting a single field but what if you want to set the widths for multiple fields?

Avatar
odoo
-

multiple fields?

Avatar
odoo
-

it didn't work for me. I am using odoo12 CE.

Avatar
odoo
-

Has anybody managed to make this work on Odoo 14?

Avatar
odoo
-

Implementing on v13. Be aware that setting up width via css or scss will break column width tree feature. So you cannot set up column width manually with mouse dragging column name.

0
Avatar
odoo
Best Answer

one thing I found in V14 is that if you define a string value to a field in the XML the minimum width is set based on that string value rather than autosizing.Note that any leading or trailing spaces are trimmed -  someone could try a non-viewable character and see if that works.

Hard to believe this issue was opened in 2013 and still open

Avatar
Discard
0
Avatar
odoo
Best Answer

This works for me in v.14

xml: tree class="my_class"

css: .my_class {column-width: XXpx;}

1 Comment
Avatar
Discard
Avatar
odoo
-

it is working for entire tree, not for each column.

0
Avatar
odoo
Best Answer

Hi I was facing the same problem and apparently in Odoo v16.

It is possible to do : 


Hope it will help someone

1 Comment
Avatar
Discard
Avatar
odoo
-

<field witdth="200px">

0
Avatar
odoo
Best Answer

I have a Field called "Name" in tree view. I want to increase the column width for this field so the data below does not take up too many lines.

Solution:

<field name="name"/>                <-----------this is the original.

<field name="name" string="    Name    "/> <---------------this is what i have done.

Please note: use ASCII code 255 for space (Alt+255)

Hope this helps someone!

Cheers!

Michael

Avatar
Discard
0
Avatar
odoo
Best Answer

I ended up solving this the following way:

I added a blank char field in my object definition, called place_holder.

Then, in my tree view I pad it with copies of this field:

<field name="place_holder/"> <field name="place_holder/"> <field name="place_holder/"> <field name="place_holder/"> <field name="place_holder/"> <field name="place_holder/"> <field name="place_holder/">

This is the only work-around I could find. Its a hack, but it does EXACTLY what I was looking for.

Hope this helps someone out there.

-Tim

1 Comment
Avatar
Discard
Avatar
odoo
-

@Tim Diamond, I am also facing the same problem of increasing width for a particular field in tree/grid view of purchase order line, can you provide me your suggestion