[IMP] project: prevent assigning non-personal stages to private tasks
Before this commit, it was possible to assign a non-personal stage on a private task, which is a nonsense as the task does not belong to a project. Only personal stages should be set to a private task. After this commit, if a non-personal stage is set on a private task, a UserError is raised. task-2818486 Part-of: odoo/odoo#89041
This commit is contained in:
committed by
Laurent Stukkens (LTU)
parent
d861aca548
commit
47f453c1d4
@@ -1859,6 +1859,9 @@ class Task(models.Model):
|
||||
vals["company_id"] = self.env["project.project"].browse(
|
||||
project_id
|
||||
).company_id.id or self.env.company.id
|
||||
if not project_id and ("stage_id" in vals or self.env.context.get('default_stage_id')):
|
||||
vals["stage_id"] = False
|
||||
|
||||
if project_id and "stage_id" not in vals:
|
||||
# 1) Allows keeping the batch creation of tasks
|
||||
# 2) Ensure the defaults are correct (and computed once by project),
|
||||
@@ -1930,6 +1933,9 @@ class Task(models.Model):
|
||||
raise UserError(_('Archived tasks cannot be recurring. Please unarchive the task first.'))
|
||||
# stage change: update date_last_stage_update
|
||||
if 'stage_id' in vals:
|
||||
if not 'project_id' in vals and self.filtered(lambda t: not t.project_id):
|
||||
raise UserError(_('You can only set a personal stage on a private task.'))
|
||||
|
||||
vals.update(self.update_date_end(vals['stage_id']))
|
||||
vals['date_last_stage_update'] = now
|
||||
# reset kanban state when changing stage
|
||||
|
||||
Reference in New Issue
Block a user