Odoo Help

Welcome!

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.

0

how can I change the color of a field in list view based on the value of a boolean field in same view?

By
John Baldwin
on 2/17/15, 4:42 PM 605 views

I have a list view with a phone field named 'phone'.  I have a boolean on my form view for a "Do Not Call List" named 'dnc'. I've added dnc to my list view and made it invisible. I would like my phone field to be red where dnc==True. Everything I've tried fails. 

<record id="res_partner_view_tree" model="ir.ui.view">
            <field name="name">res.partner.view.tree</field>
            <field name="model">res.partner</field>
            <field eval="8" name="priority"/>
            <field name="inherit_id" ref="base.view_partner_tree"/>
            <field name="arch" type="xml">
                <xpath expr="//tree" position="replace">
                    <tree string="Contacts" colors="red:dnc=='1'">
                        <field name="display_name"/>
                        <field name="function" invisible="1"/>
                        <field name="street"/>
                        <field name="street2"/>
                        <field name="city"/>
                        <field name="state_id"/>
                        <field name="zip"/>
                        <field name="dnc"/>
                        <field name="phone"/>
                        <field name="email"/>
                        <field name="user_id" invisible="1"/>
                        <field name="is_company" invisible="1"/>
                        <field name="country_id" invisible="1"/>
                        <field name="parent_id" invisible="1"/>
                    </tree>
                </xpath>
            </field>
        </record>

0
John Baldwin
On 2/17/15, 4:50 PM

Found my mistake... bolleans have to be compared without ' '... 

<tree string="Contacts" colors="red:dnc==1"> <<<works.

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)

Stats

Asked: 2/17/15, 4:42 PM
Seen: 605 times
Last updated: 3/16/15, 8:10 AM