summaryrefslogtreecommitdiff
path: root/addons/project/models/project_task_recurrence.py
diff options
context:
space:
mode:
authorVictor Feyens <vfe@odoo.com>2020-12-17 11:16:36 +0000
committerVictor Feyens <vfe@odoo.com>2020-12-17 11:39:56 +0000
commite4943afef0f66703bafd78780764ff6f0b039d3e (patch)
tree7b92f3fac946f65a5a9e2c77f2bae50d0b40a545 /addons/project/models/project_task_recurrence.py
parente7be857bea964628b80d4d3c1314dc231e0da947 (diff)
[FIX] project: fix infinite recurring tasks creation
for repeat_type = 'forever' recurrences. Consider a recurrence creating a task every 15th day of the month. When the cron runs, it updates the next recurrence dates of the recurrence. But currently, the updated "next_recurrence_date" can be set to an earlier date than today, if the fixed day of the recurring task is earlier than the current day. This means that the recurring task to create every 15th of the month will be created the 15, the 16, the 17, the 18, ... until the next month begins (no task will be created when the cron runs before the 15th of a month). This commit enforces the next recurrence_date to be set after the current cron run, to ensure a task isn't wrongly created multiple times. This commit also includes the tests that led to the discovery of this bug. closes odoo/odoo#63518 Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
Diffstat (limited to 'addons/project/models/project_task_recurrence.py')
-rw-r--r--addons/project/models/project_task_recurrence.py3
1 files changed, 3 insertions, 0 deletions
diff --git a/addons/project/models/project_task_recurrence.py b/addons/project/models/project_task_recurrence.py
index 14be6ca224c..0202a12f878 100644
--- a/addons/project/models/project_task_recurrence.py
+++ b/addons/project/models/project_task_recurrence.py
@@ -182,6 +182,9 @@ class ProjectTaskRecurrence(models.Model):
count = delta.years * 12 + delta.months
for i in range(count):
start = start.replace(day=min(repeat_day, monthrange(start.year, start.month)[1]))
+ if i == 0 and start < date_start:
+ # Ensure the next recurrence is in the future
+ start += relativedelta(months=repeat_interval)
dates.append(start)
start += relativedelta(months=repeat_interval)
return dates