This question has been flagged

Hi,

I have a new field department_ids for additional department in employee. So when i search for department name(Sales) in filter i need to get all employees whose department_id or department_ids is Sales.

I tried to add like below:

<field name="department_id" string="Departments" filter_domain="['|',('department_id', '=', self),('department_ids', '=', self)]"/>

But its not working, because department_ids is Many2many field.

Is there any solution that i can use both department_id and department_ids in same filter.


Thanks in advance.

Avatar
Discard
Best Answer

The format is correct, but make sure the right leaf is a tuple or list of values.

eg:

'message_partner_ids', 'in', [user.partner_id.id]
Avatar
Discard
Author

I need to use this domain in search view. In search view how to use many2many field?

<filter invisible="1" string="Future Activities" name="activities_upcoming_all"

domain="[('activity_ids.date_deadline', '&gt;', context_today().strftime('%Y-%m-%d'))]"/>

Here x2many field is being searched.

Author

Thank you @Hilar it worked. I have added the following in search

filter_domain="['|',('department_id', '=', self),('department_ids.name', '=', self)]"

Great, but if user search integers in your search with current search, what will happen, please make sure, I think error prone

On Wed, 12 Aug 2020, 4:49 pm silpa m s, <silpams08@gmail.com> wrote:

Thank you @Hilar it worked. I have added the following in search

filter_domain="['|',('department_id', '=', self),('department_ids.name', '=', self)]"

Envoyé par Odoo S.A. utilisant Odoo.