Odoo is the world's easiest all-in-one management software. It includes hundreds of business apps:
CRM | e-Commerce | Accounting | Inventory | PoS | Project management | MRP | etc.
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.
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.
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)]"/>
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 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.Register
Odoo Training Center
Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.Test it now
|Asked: 8/5/15, 12:45 AM|
|Seen: 1871 times|
|Last updated: 8/17/15, 4:22 AM|