From 0fbc128033466d5c0af3ee468e35e00bad036c04 Mon Sep 17 00:00:00 2001 From: Aaron Bohy Date: Fri, 4 Dec 2015 10:20:22 +0100 Subject: [PATCH] [FIX] mail: followers: subtypes: correctly notify channels Except for messages, activities on a document like internal notes posted trigger notifications to partners and channels following the corresponding activity's subtype. Rev. 69ed801 rightly re-introduces a filter on followers to prevent notifying more partners than necessary. Unfortunately, this filter doesn't take into account channels, which are thus automatically removed from followers to notify, whatever the subtypes they follow, e.g. internal notes on a document don't appear in channels following the 'Note' subtype of this document. This commit makes sure that channels always pass through that filter, but warns users that public channels should probably not following internal subtypes. Also makes the edit subtypes dialog html valid (li's must be inside, e.g., ul). --- addons/mail/models/mail_message.py | 2 +- addons/mail/static/src/js/chatter.js | 21 ++++++++++++++------- addons/mail/static/src/less/chatter.less | 7 +++++-- addons/mail/static/src/xml/chatter.xml | 6 ++++++ 4 files changed, 26 insertions(+), 10 deletions(-) diff --git a/addons/mail/models/mail_message.py b/addons/mail/models/mail_message.py index e7b40727029..306137fa723 100644 --- a/addons/mail/models/mail_message.py +++ b/addons/mail/models/mail_message.py @@ -908,7 +908,7 @@ class Message(models.Model): ('res_id', '=', self.res_id) ]).filtered(lambda fol: self.subtype_id in fol.subtype_ids) if self_sudo.subtype_id.internal: - followers = followers.filtered(lambda fol: fol.partner_id.user_ids and group_user in fol.partner_id.user_ids[0].mapped('groups_id')) + followers = followers.filtered(lambda fol: fol.channel_id or (fol.partner_id.user_ids and group_user in fol.partner_id.user_ids[0].mapped('groups_id'))) channels = self_sudo.channel_ids | followers.mapped('channel_id') partners = self_sudo.partner_ids | followers.mapped('partner_id') else: diff --git a/addons/mail/static/src/js/chatter.js b/addons/mail/static/src/js/chatter.js index ddd1aa5f5e0..15e51c253e2 100644 --- a/addons/mail/static/src/js/chatter.js +++ b/addons/mail/static/src/js/chatter.js @@ -114,7 +114,7 @@ var Followers = form_common.AbstractField.extend({ var follower_id = $currentTarget.data('oe-id'); var is_channel = $currentTarget.data('oe-model') === 'mail.channel'; self.dialog = new Dialog(this, { - size: 'small', + size: 'medium', title: _t('Edit Subscription of ') + $currentTarget.siblings('a').text(), buttons: [ { @@ -131,7 +131,7 @@ var Followers = form_common.AbstractField.extend({ }, ], }).open(); - return self.fetch_subtypes($currentTarget.data('id')); + return self.fetch_subtypes($currentTarget.data('id'), $currentTarget.data('oe-model')); }, on_invite_follower: function (channel_only) { @@ -270,8 +270,10 @@ var Followers = form_common.AbstractField.extend({ /** Fetch subtypes, only if current user is follower or if follower_id is given, i.e. if * the current user is editing the subtypes of another follower + * @param {int} [follower_id] the id of the follower + * @param {string} [follower_model] 'res.partner' or 'mail.channel' */ - fetch_subtypes: function (follower_id) { + fetch_subtypes: function (follower_id, follower_model) { var self = this; var dialog = false; @@ -292,7 +294,7 @@ var Followers = form_common.AbstractField.extend({ res_id: this.view.datarecord.id, follower_id: follower_id, }).then(function (data) { - self.display_subtypes(data, dialog); + self.display_subtypes(data, dialog, (follower_model === 'mail.channel')); }); } else { return $.Deferred().resolve(); @@ -300,11 +302,11 @@ var Followers = form_common.AbstractField.extend({ }, /** Display subtypes: {'name': default, followed} */ - display_subtypes:function (data, dialog) { + display_subtypes:function (data, dialog, display_warning) { var old_parent_model; var $list; if (dialog) { - $list = this.dialog.$el; + $list = $('