Skip to Content
Menu
This question has been flagged
1 Reply
322 Views

How can I create a custom filter where the selection criteria are expressed across company contacts and person contacts? For example, I'd like to search for all person contacts who have a specific tag who are associated with company contacts that have a different specific tag. The result would be a list that contains only contacts that meet the individual and company search criteria.

Avatar
Discard
Best Answer

To verify the filter that is created (or to even manually create the expression) I'd suggest you to first enable the Developer mode (https://www.odoo.com/documentation/18.0/applications/general/developer_mode.html). Doing so you will see additional information when creating a filter.

Furthermore, I'd like to suggest you to save the created search (even if it's just partial one at that point) as a favorite. This way you can establish a base line filtering and work from there without constantly needing to rebuild the filter from scratch all the time.

That being said, a filter meeting your criteria could look like this:

["&", ("parent_id.category_id", "in", [10, 11]), ("category_id", "in", [8, 9])]

Note: 
category_id 8 = 'abc'
category_id 9 = 'xyz'
category_id 10 = '123'
category_id 11 = '456'

The sample set of data looks like this:


With above filter, you're result will be:


Whether or not you want '=' (is equal) or 'has' (in) filters, depends on your exact requirement. But, given above Search Domain snippet (a Search Domain is a filter expression) you should be able to easily tweak it. You can also copy and paste it into the 'Code editor' field in the Custom Filter (when Developer Mode is active.

The UI version of this filter looks like this:

Avatar
Discard
Related Posts Replies Views Activity
3
Sep 25
398
1
Sep 25
1787
0
Jul 25
1083
1
May 25
1774
1
May 25
5060