Se rendre au contenu
Menu
Cette question a été signalée
3 Réponses
11791 Vues

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.


Avatar
Ignorer
Meilleure réponse

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.

Avatar
Ignorer

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.

Meilleure réponse

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.

Avatar
Ignorer

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

Publications associées Réponses Vues Activité
2
févr. 25
5770
1
déc. 24
1358
1
nov. 22
15913
3
août 22
12872
2
août 22
4391