Odoo Help


This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.


How to xPath with Tree attribute like change color ?

on 10/7/14, 6:54 AM 3,081 views

Via inherits I want to change customer tree view color based on condition.


How to do this ?


Atchuthan - Technical Consultant, Sodexis Inc

--Atchuthan - Technical Consultant, Sodexis Inc--
| 5 3 8
Puducherry, India
--Atchuthan - Technical Consultant, Sodexis Inc--
Passionate coder in Python/Odoo(formerly known as OpenERP).

Contact me via GMail: atchuthantu@gmail.com via Skype: atchuthan_skype
via Linkedin: http://in.linkedin.com/in/atchuthantu
Atchuthan - Technical Consultant, Sodexis Inc
On 10/7/14, 7:44 AM

I had a similar scenario for Sales order.  I hope it helps you.

        <record id="sale_view_order_tree_inherit1" model="ir.ui.view">
            <field name="name">sale.view.order.tree.inherit1</field>
            <field name="model">sale.order</field>
            <field name="type">tree</field>
            <field name="inherit_id" ref="sale.view_order_tree"/>
            <field name="arch" type="xml">
                <xpath expr="//tree[@string='Sales Orders']" position="attributes">
                    <attribute name="colors">grey:state=='cancel';orange:state in ('waiting_date','manual');red:state in ('invoice_except','shipping_except')</attribute>

On 10/7/14, 8:24 AM

First need to add new field in tree view and then add xpath to change color.

<record model="ir.ui.view" id="edi_tree_partners_extra">
                <field name="name">res.partner.extend.edi</field>
                <field name="model">res.partner</field>
                <field name="inherit_id" ref="base.view_partner_tree"/>
                <field name="arch" type="xml">
                        <xpath expr="//field[@name='display_name']" position="after">
                            <field name="blocked"/>
                        <xpath expr="//tree[@string='Contacts']" position="attributes">
                            <attribute name="colors">red:blocked==True;</attribute>



Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)


Asked: 10/7/14, 6:54 AM
Seen: 3081 times
Last updated: 3/16/15, 8:10 AM