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

I want to change the contacts tree view


Tried do it with a custom module where i have on a css file, but it doesnt changes nothing

this is the /view/templates.xml:

<odoo>
    <data>
      <template id="tree" name="Tree_View_Color" inherit_id="base.view_partner_tree">
        <xpath expr="." position="inside">
             <link href="/tree_view_color/static/src/css/style.css" rel="stylesheet" 
type="text/css"/>
        </xpath>
      </template>
    </data>
</odoo>

this is the /static/src/css/style.css:

.openerp .oe_list_content > tbody > tr:nth-child(even) {
    background-color#FF9900;
 }

i dont know where exactly did i fail, i thought maybe is on the tr declaration but im not sure 

any idea? or some tip on how to do what i want?

Thanks! (btw, the version is odoo 12)

Avatar
Discard
Best Answer

You can use the sequence field(integer) and boolean field to get the even line in true and false state then you can use the decorator in tree view to change the color of line with respect to even or odd, Note: you can put widget "handle" on sequence field to make it drag able lines.


Python:

sequence = fields.Integer(string='Sequence')
is_even_line = fields.Boolean(string='Is Even?', compute='compute_is_even_line')

def compute_is_even_line(self):
for rec in self:
if (rec.sequence % 2) == 0:
rec.is_even_line = True
else:
rec.is_even_line = False


XML:

<tree string="Tree" decoration-success="is_even_line=='True'" decoration-warning="is_even_line=='False'">
<field name='sequence' widget="handle"/>
<field name='is_even_line'/>
<field name='name'/>
</tree>
Avatar
Discard

Done