Odoo Help


How to restrict drop down values of many2one field according to a condition ?

aneesh ATEES Infomedia Pvt Ltd
on 8/5/15, 12:45 AM 3,196 views


How to restrict drop down values of many2one field accounding to perticular condition?

ie) I need to show only cretain values, according to a perticular condition in many to one field


'section_id': fields.many2one('crm.case.section', 'Sales Team'),

I need to show only perticular 'section_id' values as If 'section_id' = 2.


Ankit H Gandhi(AHG)

--Ankit H Gandhi(AHG)--

| 6 5 6
Baroda, India
--Ankit H Gandhi(AHG)--

Learning Python..

Ankit H Gandhi(AHG)
On 8/5/15, 1:55 AM

Dear aneesh,

You sholud use the domain for condition. we can set domain in two ways

1. python file.

2. xml file.

we can choose any one way to set the domain.

So you should use domain like this

in python file

'section_id': fields.many2one('crm.case.section', 'Sales Team', domain="[('section_id', '=', 2)]")


in xml file

<field name="section_id" domain="[('section_id', '=', 2)]"/>

Thanks & Regards

Ankit H Gandhi.

could the domain be dynamic, i.e, the 2 added in the domain could be any number based on a value entered in another field?

Tarek Mohamed Ibrahim
on 8/5/15, 7:11 AM

Yes, you can set it dynamic.but your new field is related to each other.

Ankit H Gandhi(AHG)
on 8/5/15, 8:11 AM

Vale Trood

--Vale Trood--

| 5 2 7
Tunis, France
--Vale Trood--

Vale Trood
On 8/5/15, 7:16 AM

Hi friend:

You have to add the domain which defines your condition.So, you can do it by two ways:

Either in your python file.

Or in your  xml file.

Here is an example: where field_a is the field that you want on it the many_2_one depends.(any number based on a value entered in another field?)


'section_id': fields.many2one('crm.case.section', 'Sales Team', domain="[('section_id', '=', field_a)]")



<field name="section_id" domain="[('section_id', '=', field_a)]"/>


Friend, if its what you are looking for vote ;)

Vale Trood
on 8/5/15, 7:17 AM

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

1 follower(s)


Asked: 8/5/15, 12:45 AM
Seen: 3196 times
Last updated: 8/17/15, 4:22 AM