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

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

Avatar
Discard

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

thank you

Best Answer

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

Avatar
Discard

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';">

Related Posts Replies Views Activity
3
Apr 24
1972
0
Dec 19
4729
5
Oct 24
1962
3
Aug 22
4333
3
Dec 17
2990