Does anybody have experience with the following problem or any idea how to solve it:
I want to fold or hide specific Kanban-stages dependent on a Boolean parameter in the context.
I found a working solution to completely hide kanban stages depending on the context (here: job_id).
This function from hr.applicant does the trick:
stage_id = fields.Many2one(
group_expand='_read_group_stage_ids')
@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')
search_domain = [('job_ids', '=', False)]
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)