From cb26f1aabdbd53f1ce9650659a256ce9c994391d Mon Sep 17 00:00:00 2001 From: snd Date: Wed, 1 Jul 2020 09:32:04 +0000 Subject: [PATCH] [FIX] project - send rating mail by project opws: 2269230, 2248760 When a database has a lot of projects with many tasks, and needs to send a lot of feedback mails, the cron tries to send mails to all tasks at the same time, thus it times out. This fix will allow to treat projects one at a time so that when the cron times out, it will not restart from the beginning. closes odoo/odoo#53922 X-original-commit: 07c828b48741500573b4286480b23752a28163c7 Signed-off-by: Yannick Tivisse (yti) --- addons/project/models/project.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/addons/project/models/project.py b/addons/project/models/project.py index 8c05f3228d3..2355eba348f 100644 --- a/addons/project/models/project.py +++ b/addons/project/models/project.py @@ -483,8 +483,10 @@ class Project(models.Model): @api.model def _send_rating_all(self): projects = self.search([('rating_status', '=', 'periodic'), ('rating_request_deadline', '<=', fields.Datetime.now())]) - projects.mapped('task_ids')._send_task_rating_mail() - projects._compute_rating_request_deadline() + for project in projects: + project.task_ids._send_task_rating_mail() + project._compute_rating_request_deadline() + self.env.cr.commit() class Task(models.Model):