diff --git a/odex25_project/project_base/models/project_task.py b/odex25_project/project_base/models/project_task.py index 695c62aef..4740aa901 100644 --- a/odex25_project/project_base/models/project_task.py +++ b/odex25_project/project_base/models/project_task.py @@ -62,15 +62,16 @@ class ProjectTask(models.Model): department_manager_users = self.env.ref('project_base.group_project_department_manager').users # Combine both user sets user_ids = manager_users | department_manager_users - self.env['mail.message'].create({ - 'message_type': "notification", - 'body': _("Task %s is done for project %s and needs your action") % (self.name, self.project_id.project_no or ""), - 'subject': _("Done Task"), - 'partner_ids': [(6, 0, user_ids.mapped('partner_id').ids)], - 'notification_ids': [(0, 0, {'res_partner_id': user.partner_id.id, 'notification_type': 'inbox'}) - for user in user_ids if user_ids], - 'model': self._name, - 'res_id': self.id, - 'author_id': self.env.user.partner_id and self.env.user.partner_id.id - }) + if self.stage_id.is_closed: + self.env['mail.message'].create({ + 'message_type': "notification", + 'body': _("Task %s is done for project %s and needs your action") % (self.name, self.project_id.project_no or ""), + 'subject': _("Done Task"), + 'partner_ids': [(6, 0, user_ids.mapped('partner_id').ids)], + 'notification_ids': [(0, 0, {'res_partner_id': user.partner_id.id, 'notification_type': 'inbox'}) + for user in user_ids if user_ids], + 'model': self._name, + 'res_id': self.id, + 'author_id': self.env.user.partner_id and self.env.user.partner_id.id + })