[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) <ltu@odoo.com>
This commit is contained in:
Raouf
2022-11-18 15:00:53 +01:00
parent 5c555995ee
commit f9242db25f
+5 -4
View File
@@ -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