diff options
Diffstat (limited to 'addons/mail/models/mail_thread.py')
| -rw-r--r-- | addons/mail/models/mail_thread.py | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/addons/mail/models/mail_thread.py b/addons/mail/models/mail_thread.py index f9a50041dc0..2b2cb9354a1 100644 --- a/addons/mail/models/mail_thread.py +++ b/addons/mail/models/mail_thread.py @@ -2811,9 +2811,10 @@ class MailThread(models.AbstractModel): new_partners, new_channels = dict(), dict() - # fetch auto subscription subtypes data + # return data related to auto subscription based on subtype matching (aka: + # default task subtypes or subtypes from project triggering task subtypes) updated_relation = dict() - all_ids, def_ids, int_ids, parent, relation = self.env['mail.message.subtype']._get_auto_subscription_subtypes(self._name) + child_ids, def_ids, all_int_ids, parent, relation = self.env['mail.message.subtype']._get_auto_subscription_subtypes(self._name) # check effectively modified relation field for res_model, fnames in relation.items(): @@ -2822,15 +2823,21 @@ class MailThread(models.AbstractModel): udpated_fields = [fname for fnames in updated_relation.values() for fname in fnames if updated_values.get(fname)] if udpated_fields: + # fetch "parent" subscription data (aka: subtypes on project to propagate on task) 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, include_active=True) for fid, rid, pid, cid, subtype_ids, pshare, active in res: + # use project.task_new -> task.new link 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] + # add checked subtypes matching model_name + sids += [sid for sid in subtype_ids if sid not in parent and sid in child_ids] 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) + if pshare: # remove internal subtypes for customers + new_partners[pid] = set(sids) - set(all_int_ids) + else: + new_partners[pid] = set(sids) + if cid: # never subscribe channels to internal subtypes + new_channels[cid] = set(sids) - set(all_int_ids) notify_data = dict() res = self._message_auto_subscribe_followers(updated_values, def_ids) |
