Skip to Content
Меню
Вам необхідно зареєструватися, щоб взаємодіяти зі спільнотою.
Це запитання позначене
3 Відповіді
11788 Переглядів

Hi,

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


Example:

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

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


Аватар
Відмінити
Найкраща відповідь

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)]")

or

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?

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

Найкраща відповідь

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?)

 Python:

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

or

XML:

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

Regards.

Аватар
Відмінити

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

Related Posts Відповіді Переглядів Дія
2
лют. 25
5770
1
груд. 24
1356
1
лист. 22
15913
3
серп. 22
12872
2
серп. 22
4391