From f9242db25fcc4dd5111dbecd013b90e901d9044d Mon Sep 17 00:00:00 2001 From: Raouf Date: Wed, 8 Jun 2022 10:50:32 +0000 Subject: [PATCH] [IMP] project: change kanban_state to normal when changing task project_id Before this commit: When task project is changed in through the view the kanban_state remain the same until the record is saved. After this commit: When changing project, kanban_state is changed to 'normal' direclty. task-2849291 closes odoo/odoo#91174 Related: odoo/upgrade#3523 Related: odoo/enterprise#27287 Signed-off-by: Laurent Stukkens (ltu) --- addons/project/models/project.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/addons/project/models/project.py b/addons/project/models/project.py index b1f43282285..cc27a7b30b8 100644 --- a/addons/project/models/project.py +++ b/addons/project/models/project.py @@ -1105,7 +1105,7 @@ class Task(models.Model): ('normal', 'In Progress'), ('done', 'Ready'), ('blocked', 'Blocked')], string='Status', - copy=False, default='normal', required=True) + copy=False, default='normal', required=True, compute='_compute_kanban_state', readonly=False, store=True) kanban_state_label = fields.Char(compute='_compute_kanban_state_label', string='Kanban State Label', tracking=True, task_dependency_tracking=True) create_date = fields.Datetime("Created On", readonly=True) write_date = fields.Datetime("Last Updated On", readonly=True) @@ -1365,6 +1365,10 @@ class Task(models.Model): node.set('invisible', '1') return arch, view + @api.depends('stage_id', 'project_id') + def _compute_kanban_state(self): + self.kanban_state = 'normal' + @api.depends('parent_id.ancestor_id') def _compute_ancestor_id(self): for task in self: @@ -2049,9 +2053,6 @@ class Task(models.Model): vals.update(self.update_date_end(vals['stage_id'])) vals['date_last_stage_update'] = now - # reset kanban state when changing stage - if 'kanban_state' not in vals: - vals['kanban_state'] = 'normal' task_ids_without_user_set = set() if 'user_ids' in vals and 'date_assign' not in vals: # prepare update of date_assign after super call