From 4f4c643a0b3f303912fd4fe85e2feb8e8d3eb33e Mon Sep 17 00:00:00 2001 From: Kevin Baptiste Date: Mon, 23 Nov 2020 08:39:53 +0000 Subject: [PATCH] [FIX] project: don't send rating email when disabled on project The rating emails were still sent even if the rating feature was disabled on the specific project. This commit ensures the emails are only sent to project with the feature enabled. closes odoo/odoo#62181 Taskid: 2390802 X-original-commit: 3fe5416f07e76ccca6c0bb05a6fa12d8e2ca0e6c Signed-off-by: Yannick Tivisse (yti) Signed-off-by: Kevin Baptiste --- addons/project/models/project.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/addons/project/models/project.py b/addons/project/models/project.py index 0cb3ddb513f..95640828288 100644 --- a/addons/project/models/project.py +++ b/addons/project/models/project.py @@ -520,7 +520,11 @@ class Project(models.Model): # This method should be called once a day by the scheduler @api.model def _send_rating_all(self): - projects = self.search([('rating_status', '=', 'periodic'), ('rating_request_deadline', '<=', fields.Datetime.now())]) + projects = self.search([ + ('rating_active', '=', True), + ('rating_status', '=', 'periodic'), + ('rating_request_deadline', '<=', fields.Datetime.now()) + ]) for project in projects: project.task_ids._send_task_rating_mail() project._compute_rating_request_deadline() @@ -1128,7 +1132,7 @@ class Task(models.Model): result = super(Task, tasks).write(vals) # rating on stage if 'stage_id' in vals and vals.get('stage_id'): - self.filtered(lambda x: x.project_id.rating_status == 'stage')._send_task_rating_mail(force_send=True) + self.filtered(lambda x: x.project_id.rating_active and x.project_id.rating_status == 'stage')._send_task_rating_mail(force_send=True) return result def update_date_end(self, stage_id):