Passa al contenuto
Menu
È necessario essere registrati per interagire con la community.
La domanda è stata contrassegnata
1 Rispondi
9938 Visualizzazioni

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
Abbandona

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

thank you

Risposta migliore

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
Abbandona

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

Post correlati Risposte Visualizzazioni Attività
3
apr 24
2400
0
dic 19
5777
5
ott 24
6198
3
ago 22
7684
3
dic 17
4348