From 9b4cef63f0e04c690ad688118287d99dbc27f38d Mon Sep 17 00:00:00 2001 From: clementthomas Date: Tue, 28 Mar 2023 16:09:14 +0200 Subject: [PATCH] [IMP] project_assignees: chatter auto subscription to assignees --- project_assignees/models/project_task.py | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/project_assignees/models/project_task.py b/project_assignees/models/project_task.py index 7db36ff..b62bc6e 100644 --- a/project_assignees/models/project_task.py +++ b/project_assignees/models/project_task.py @@ -1,5 +1,5 @@ -from odoo import models, fields, _ +from odoo import models, fields, _, api class Task(models.Model): @@ -7,3 +7,20 @@ class Task(models.Model): assignee_ids = fields.Many2many('res.users', 'assignee_ids_rel', string='Other Assignees') + @api.multi + def subscribe_assignees(self): + for task in self: + partner_ids = [a.partner_id.id for a in self.assignee_ids] + task.message_subscribe(partner_ids) + + @api.multi + def write(self, vals): + result = super(Task, self).write(vals) + self.subscribe_assignees() + return result + + @api.model + def create(self, vals): + task = super(Task, self).create(vals) + task.subscribe_assignees() + return task \ No newline at end of file