Via inherits I want to change customer tree view color based on condition.
How to do this ?
Odoo is the world's easiest all-in-one management software.
 It includes hundreds of business apps:
Via inherits I want to change customer tree view color based on condition.
How to do this ?
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>
</xpath>
</field>
</record>
<xpath expr="//tree[1]" position="attributes">
<attribute name="create">false</attribute>
</xpath>
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">
                    <data>
                        <xpath expr="//field[@name='display_name']" position="after">
                            <field name="blocked"/>
                        </xpath>
                        <xpath expr="//tree[@string='Contacts']" position="attributes">
                            <attribute name="colors">red:blocked==True;</attribute>
                        </xpath>
                    </data>
                </field>
                </record>
Crea un account oggi per scoprire funzionalità esclusive ed entrare a far parte della nostra fantastica community!
Registrati| Post correlati | Risposte | Visualizzazioni | Attività | |
|---|---|---|---|---|
|  | 0 apr 20  | 4283 | ||
|  | 1 ago 19  | 7077 | ||
|  | 1 ott 16  | 7283 | ||
|  | 2 mar 15  | 13184 | ||
|  | 1 feb 25  | 3136 |