I have this code. I need a function that filters all Tasks out that are in stage == "finished" . How Can I make that?
When the task is in stage finished it should't show up in the selector of all tasks.
This function shows me all tasks from a project and again all tasks that are in stage_id == finished
How Can I make that so, that all "finished" tasks are not showing in this selector include_in_task_work_view???
class ProjectWork(models.Model):
_inherit = 'project.task.work'
project = fields.Many2one(
string='Project', related='task_id.project_id', store=True,
domain="[('state', 'not in', ('template', 'cancelled', 'close'))]")
include_in_task_work_view = fields.Boolean(
related='task_id.stage_id.include_in_task_work_view', readonly=True,
store=True)
@api.onchange('project')
def onchange_project(self):
if not self.project:
return {'domain': {'task_id': []}}
return {
'domain': {
'task_id': [('project_id', '=', self.project.id),
('include_in_task_work_view', '=', True)]},
}
@api.onchange('task_id')
def onchange_task_id(self):
if not self.task_id:
return {}
return {'value': {'project': self.task_id.project_id.id}}