Search code examples
odooodoo-view

Extend list view and add custom styling


I am working with one2many list view and there is a state column in that i want to add custom css based on state of the object. Like if state is Completed make the text bold and background green somthing like that for other states. I tried but didn't found any way to add custom css or css classes based on condition. So i am now trying to extend list view in javascript and then i will loop through all rows and then add colors on them . Is this possible in Odoo ?


Solution

  • This can help if you want to change the entire row:

    <field name="line_ids" >
        <tree string="Lines" colors="red:state=='completed'" fonts="bold:state=='completed'">
            <field name="name"/>
            <field name="employee_id"/>
            <field name="state"/>
        </tree>
    </field>
    

    But if you want to change just one column maybe this post can help you: Bold in listview for many records

    I hope I've helped.