'Odoo 13: Contacts: Filter/Search - Get all individuals of companies with condition (category_id == 'Services')

Module Contacts: How to get all individuals of companies with a certain condition (e.g. category_id == 'Services'). Obviously condition may vary. I would like to use it in filter or search functions.



Solution 1:[1]

all_companies_with_service = self.env['res.partner'].search([('category_id', '=', 'services')]).ids

patners = self.env['res.partner'].search(['&',('company_id', 'in', all_companies_with_service), ('is_company', '=', False)])

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1