diff options
| author | Thibault Delavallée <tde@odoo.com> | 2020-08-26 12:45:54 +0000 |
|---|---|---|
| committer | Thibault Delavallée <tde@odoo.com> | 2020-08-28 12:42:32 +0000 |
| commit | 42910ce25f06a31af3cfbc8d5d41e443ee754c34 (patch) | |
| tree | c06be39f88bf700959ceb2e72bf8098a408cde0f /addons/mail/models/mail_thread.py | |
| parent | f45d7ace687911f4090c081bdc0e8127c382bd64 (diff) | |
[IMP] mail: do not auto-subscribe inactive partners
Tested flows
* posting a message through an inactive partner (like automated actions
posting a message on behalf of an inactive partner);
* automatic subscription based on parent record (like an archived user and
partner following a project that should not be added as follower of sub
tasks);
* automatic subscription based on responsible field: this is already fixed
as user has to be active to receive a notification and be added in
followers;
LINKS
Task ID-2326281
PR odoo/odoo#56560
Diffstat (limited to 'addons/mail/models/mail_thread.py')
| -rw-r--r-- | addons/mail/models/mail_thread.py | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/addons/mail/models/mail_thread.py b/addons/mail/models/mail_thread.py index 96a78aa6079..44527232803 100644 --- a/addons/mail/models/mail_thread.py +++ b/addons/mail/models/mail_thread.py @@ -1870,8 +1870,8 @@ class MailThread(models.AbstractModel): self._message_set_main_attachment_id(values['attachment_ids']) if values['author_id'] and values['message_type'] != 'notification' and not self._context.get('mail_create_nosubscribe'): - # if self.env['res.partner'].browse(values['author_id']).active: # we dont want to add odoobot/inactive as a follower - self._message_subscribe([values['author_id']]) + if self.env['res.partner'].browse(values['author_id']).active: # we dont want to add odoobot/inactive as a follower + self._message_subscribe([values['author_id']]) self._message_post_after_hook(new_message, values) self._notify_thread(new_message, values, **notif_kwargs) @@ -2801,11 +2801,11 @@ class MailThread(models.AbstractModel): if udpated_fields: doc_data = [(model, [updated_values[fname] for fname in fnames]) for model, fnames in updated_relation.items()] - res = self.env['mail.followers']._get_subscription_data(doc_data, None, None, include_pshare=True) - for fid, rid, pid, cid, subtype_ids, pshare in res: + res = self.env['mail.followers']._get_subscription_data(doc_data, None, None, include_pshare=True, include_active=True) + for fid, rid, pid, cid, subtype_ids, pshare, active in res: sids = [parent[sid] for sid in subtype_ids if parent.get(sid)] sids += [sid for sid in subtype_ids if sid not in parent and sid in def_ids or sid in int_ids] - if pid: + if pid and active: # auto subscribe only active partners new_partners[pid] = (set(sids) & set(all_ids)) - set(int_ids) if pshare else set(sids) & set(all_ids) if cid: new_channels[cid] = (set(sids) & set(all_ids)) - set(int_ids) |
