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

Hi Odoo developers,
I want to set a background color for a specific tree view in a one2many field.How can i achieve this or is there any custom application available for this?
Thanks

아바타
취소

is there a méthode to change specific rows in tree view (condition) , but not all rows

thank you

베스트 답변

Hi,

You can try the following steps for getting color to one2many field

Include your one2many field inside a div like below

<div class="background_black">
<field name="order_lines" attrs="{'readonly': [('state','!=','draft')]}"
style="background-color: #404040 !important;">
<tree string="Laundry Order Lines" editable="bottom"
decoration-info="state == 'draft'"
colors="grey:state == 'done';black:state == 'extra_work';green:state == 'wash';">
<field name="product_id"/>
<field name="description"/>
<field name="qty"/>
<field name="washing_type"/>
<field name="extra_work" widget="many2many_tags"/>
<field name="state"/>
<field name="amount"/>
</tree>
</field>
</div>

Here one2many field name is order_lines and assign a class to div, in the above case it is background_black.

Now we have to define style for this div class in a css file.Define template for including the style file

<template id="assets_backend_tablet" name="Field Background" inherit_id="web.assets_backend">
<xpath expr="." position="inside">
<link rel="stylesheet" href="laundry_management/static/src/css/background.css"/>
</xpath>
</template>

laundry_management is the module name, you can use your module name.And define style like below

.background_black .o_list_view{
background-color: #404040 !important;
}

And we can get the one2many field like below


Hope it helps

아바타
취소

I tried the above method in version 14 but it doesn't work as expected.

Did you defined State? If yes, why it is not there in status bar?
If Invisible, how the states are changed based on the condition? Finally, Can you share a working module for this?

Can u describe this part?

<tree string="Laundry Order Lines" editable="bottom"
decoration-info="state == 'draft'"
colors="grey:state == 'done';black:state == 'extra_work';green:state == 'wash';">

관련 게시물 답글 화면 활동
3
4월 24
2400
0
12월 19
5805
5
10월 24
6360
3
8월 22
7772
3
12월 17
4389