Odoo Help


Set field required for specific stage

on 3/8/13, 11:54 AM 4,845 views

My initial goal was to highlight (change color of) a field label in a form view, for specific stages (NOT states). It looks like that is not yet supported (please correct me if I am wrong) so I moved on to making a field required based on what stage the document is in. In my case I am working with leads/opportunities. This post on stack overflow highlights how to do this with states, but I cannot seem to get it to work with stages. I have tried the following:

<field name="field_name" attrs="{'required':[('stage_id','=','new')]}"/>

(No results)

<field name="field_name" attrs="{'required':[('stage_id','=','1')]}"/>

(No results)

<field name="field_name" attrs="{'required':[('stage_id.name','=','New')]}"/>

(Error Unknown field stage_id.name in domain)

Is this even possible?

On 3/8/13, 12:18 PM

It looks like I have to add a related field to the lead object in order to access the stage name in this capacity.

'related_stage_name': fields.related('stage_id','name',type="char",string="stage")

and use it in the domain of the required attribute

 <field name="field_name" attrs="{'required':[('related_stage_name','=','New')]}"/>

I would still like to know if this is possible with CSS classes or colors?

This is a good answer, but I woulld like to add: Try #1 would work if you were using state instead of stage_id. Try #2 should work with a 1 instead of '1', and if 1 is the database id for the Stage "New", Try #3, I wish it could work - you can't use dot notation in these domain filters, so the solution is to create a related field.

Daniel Reis
on 3/8/13, 5:17 PM

Thanks for the followup explanation!

on 3/11/13, 10:53 AM
kazunobu ndong
On 11/29/17, 11:55 PM

Hello Allison,

I am having the same problem in Odoo 10. in the OCA'S project timeline module I am trying  to change the gantt chart color according to a specific stage. I don't fully understand your solution: are you adding this code portion in the xml file? <'related_stage_name': fields.related('stage_id','name',type="char",string="stage")>

for example in my case i have the following xml, where "stage_id==4" leads to no result:

<?xml version="1.0" encoding="utf-8"?>


    <record id="project_task_timeline" model="ir.ui.view">

        <field name="model">project.task</field>

        <field name="type">timeline</field>

        <field name="arch" type="xml">

            <timeline date_start="date_start"




                      colors="#ec7063: user_id == false; #2ecb71: stage_id == 4;">




    <record id="project.action_view_task" model="ir.actions.act_window">

        <field name="view_mode">kanban,tree,form,calendar,timeline,pivot,graph</field>


    <record id="project.act_project_project_2_project_task_all" model="ir.actions.act_window">

        <field name="view_mode">kanban,tree,form,calendar,timeline,pivot,graph</field>


    <record id="view_task_form2" model="ir.ui.view">

        <field name="name">project.task.form</field>

        <field name="model">project.task</field>

        <field name="inherit_id" ref="project.view_task_form2"/>

        <field name="arch" type="xml">

            <xpath expr="//field[@name='date_assign']" position="before">

                <field name="date_start"/>

                <field name="date_end"/>







About This Community

This platform 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.


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

0 follower(s)


Asked: 3/8/13, 11:54 AM
Seen: 4845 times
Last updated: 11/29/17, 11:55 PM