for-loop
for-loop

Reputation: 57

Odoo 13 : How to display selection field in kanban view based on Qweb and color transformation?

This is the first time I am using Qweb for Odoo XML. My code is not working as intendent due to lack of experience I guess. Thank you very much in advance.

I have a selection field :

priority = fields.Selection([('critical', 'Critical'), ('urgent', 'Urgent'), ('low', 'Low')], tracking=True, help="You can give your tas a priority")

So every selection has a different color in my form view :

 <field name="priority" decoration-danger="priority =='critical'" decoration-success="priority =='low'" decoration-warning="priority=='urgent'" class="o_project_name oe_inline"/>

I want to display the colored priority in my kanban view, but its not working as intendent :

 <record id="todo_kanban" model="ir.ui.view">
    <field name="name">todo.kanban</field>
    <field name="model">todo</field>
    <field name="arch" type="xml">
        <kanban default_group_by ="stage_id" class="o_kanban_small_column o_kanban_project_tasks" on_create="quick_create" >
            <field name="todo_id"/>
            <field name="user_id"/>
            <field name="priority"/>
            <templates>
                <t t-name="kanban-box">   
                    <div class="oe_kanban_details">
                        <strong class="o_kanban_record_title"><field name="todo_id"/></strong>
                        <div class="o_kanban_tags_section"/>
                        <ul>
                            <li>User : <field name="user_id"/></li>
                            <li>Priority : <field name="priority"/>
                                    <t t-if="priority == 'critial'">
                                        <t t-set="style" t-value="'color:red'" />
                                    </t>
                                    <t t-if="priority == 'urgent'">
                                        <t t-set="style" t-value="'color:orange'" />
                                    </t>
                                    <t t-if="priority == 'low'">
                                        <t t-set="style" t-value="'color:green'" />
                                    </t>
                            </li>
                        </ul>
                    </div>
                </t>
            </templates>
        </kanban>
    </field>
</record>

enter image description here

Upvotes: 0

Views: 407

Answers (1)

Neill
Neill

Reputation: 711

I'm not sure if you already found a solution, but you could try the following:

 <t t-if="priority == 'critial'" t-attf-style="color:red">
</t>

Upvotes: 0

Related Questions