콘텐츠로 건너뛰기
메뉴
커뮤니티에 참여하려면 회원 가입을 하시기 바랍니다.
신고된 질문입니다
11 답글
100179 화면

Hi community,

I have 4 columns in a tree view, taking up all the screen. They are very spread out, and I was wondering how to change their column widths. I"ve dug around, and found this link:

https://accounts.openerp.com/forum/Help-1/question/26693

This shows how to add custom css, and apply it on a field. I've followed the methodology exactly, and to me, it seems this only works in FORM view, not tree view. When I try to add a class to my field in tree view, I get XML errors.

Can anyone help me reduce my column widths in a tree view?

Thanks,

Tim

아바타
취소
베스트 답변

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.

아바타
취소

Works perfectly, thanks!

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

multiple fields?

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

Has anybody managed to make this work on Odoo 14?

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.

베스트 답변

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

아바타
취소
베스트 답변

This works for me in v.14

xml: tree class="my_class"

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

아바타
취소

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

베스트 답변

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

아바타
취소
베스트 답변

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

It is possible to do : 


Hope it will help someone

아바타
취소

<field witdth="200px">

베스트 답변

I solved in v16 as follows:

in style tag or css file: .custom-class table thead > tr > th:nth-child(2) {width: 150px !important;}

in tree tag: class="custom-class"

nth-child(2), where "2" is the column you want to wrap

아바타
취소
베스트 답변

Worked on v15

(removed some of the xml because it disappears after posting)


tree col="6"
field name="field1" colspan="2"
field name="field2" colspan="2"
field name="field3" colspan="2"
tree



아바타
취소
베스트 답변

I tried all the solutions below but none of this solutions work on Odoo 15. Any idea?

아바타
취소
작성자 베스트 답변

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

아바타
취소

@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

looks like same solution as above mentioned by Michael Ruban (KJK meisterHonen Pvt. Ltd.,)

베스트 답변

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;

}
아바타
취소
베스트 답변

Use group tag with colspan attribute around your fields.

아바타
취소
관련 게시물 답글 화면 활동
2
5월 24
1674
0
7월 24
1162
2
4월 21
4003
0
3월 17
2896
2
2월 24
2749