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.


Set field required for specific stage

on 3/8/13, 11:54 AM 2,882 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

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

0 follower(s)


Asked: 3/8/13, 11:54 AM
Seen: 2882 times
Last updated: 3/16/15, 8:10 AM