I work in the recruitment module. The stages in this model are filtered (by def) in the Kanban by job. I also want it filtered by company (job_id.company_id = stage_id.company_id). But it just won't work. See function below.
@api.model
def _read_group_stage_ids(self, stages, domain, order):
# retrieve job_id from the context and write the domain: ids + contextual columns (job or default)
job_id = self._context.get('default_job_id')
company_id = self.env('stage_id').company_id
_logger.info("company id: %s", company_id)
search_domain = self.env["job_id"].search([("job_id.company_id", "=", company_id)])
if job_id:
search_domain = ['|', ('job_ids', '=', job_id)] + search_domain
if stages:
search_domain = ['|', ('id', 'in', stages.ids)] + search_domain
stage_ids = stages._search(search_domain, order=order, access_rights_uid=SUPERUSER_ID)
return stages.browse(stage_ids)