Skip to content
Snippets Groups Projects
Commit 85ca6865 authored by Audric Onockx (auon)'s avatar Audric Onockx (auon)
Browse files

[FIX] project: allow subsequent update


Steps:
Say 3 existing tasks :
t0 (from which the recurrence has been created), t1, t2;
and t4 (not created yet).
When you change t0, t4 is updated as expected.

Issue:
But when you change t1, t4 doesn't take it into account.

Cause:
`ProjectTaskRecurrence._create_next_task` takes
`recurrence.task_ids[-1]` as template to create the next occurence.
Yet ProjectTask is ordered by "priority desc, sequence, id desc".
All occurrences being likely to have the same priority and sequence,
we the result ordered by id desc. So `recurrence.task_ids[-1]` has the
smallest id and so it is the oldest one.

Fix:
Take the task with the max id.

opw-3237168

closes odoo/odoo#119719

X-original-commit: 61bbd8e6
Signed-off-by: default avatarXavier Bol (xbo) <xbo@odoo.com>
parent 40f157e5
Branches
Tags
No related merge requests found
......@@ -246,7 +246,7 @@ class ProjectTaskRecurrence(models.Model):
def _create_next_task(self):
for recurrence in self:
task = recurrence.sudo().task_ids[-1]
task = max(recurrence.sudo().task_ids, key=lambda t: t.id)
create_values = recurrence._new_task_values(task)
new_task = self.env['project.task'].sudo().create(create_values)
recurrence._create_subtasks(task, new_task, depth=3)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment