Passa al contenuto
Menu
È necessario essere registrati per interagire con la community.
La domanda è stata contrassegnata
3 Risposte
11799 Visualizzazioni

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
Abbandona
Risposta migliore

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
Abbandona

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.

Risposta migliore

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
Abbandona

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

Post correlati Risposte Visualizzazioni Attività
2
feb 25
5774
1
dic 24
1365
1
nov 22
15915
3
ago 22
12874
2
ago 22
4397