diff --git a/addons/mail/mail_thread.py b/addons/mail/mail_thread.py index cb07cb91a6f..0f9d1956fb3 100644 --- a/addons/mail/mail_thread.py +++ b/addons/mail/mail_thread.py @@ -859,7 +859,11 @@ class mail_thread(osv.AbstractModel): def message_unsubscribe(self, cr, uid, ids, partner_ids, context=None): """ Remove partners from the records followers. """ - self.check_access_rights(cr, uid, 'read') + user_pids = self.pool.get('res.users').read(cr, uid, uid, ['partner_id'], context=context)['partner_id'] + if set(partner_ids) == set(user_pids): + self.check_access_rights(cr, uid, 'read') + else: + self.check_access_rights(cr, uid, 'write') return self.write(cr, SUPERUSER_ID, ids, {'message_follower_ids': [(3, pid) for pid in partner_ids]}, context=context) #------------------------------------------------------ diff --git a/addons/mail/static/src/css/mail.css b/addons/mail/static/src/css/mail.css index 886199a668b..c0a28551e5c 100644 --- a/addons/mail/static/src/css/mail.css +++ b/addons/mail/static/src/css/mail.css @@ -586,6 +586,11 @@ margin-right:4px; border-radius: 2px; } +.openerp .oe_followers .oe_remove_follower{ + cursor: pointer; + float: right; + +} /* ---------------- MESSAGES BODY ------------------ */ .openerp .oe_mail .oe_msg_content .oe_blockquote, diff --git a/addons/mail/static/src/js/mail_followers.js b/addons/mail/static/src/js/mail_followers.js index de77aec4244..f0114be33f4 100644 --- a/addons/mail/static/src/js/mail_followers.js +++ b/addons/mail/static/src/js/mail_followers.js @@ -69,27 +69,38 @@ openerp_mail_followers = function(session, mail) { // event: click on a subtype, that (un)subscribe for this subtype this.$el.on('click', '.oe_subtype_list input', self.do_update_subscription); // event: click on 'invite' button, that opens the invite wizard - this.$('.oe_invite').on('click', function (event) { - action = { - type: 'ir.actions.act_window', - res_model: 'mail.wizard.invite', - view_mode: 'form', - view_type: 'form', - views: [[false, 'form']], - target: 'new', - context: { - 'default_res_model': self.view.dataset.model, - 'default_res_id': self.view.datarecord.id, - }, - } - self.do_action(action, { - on_close: function() { - self.read_value(); - }, - }); + this.$('.oe_invite').on('click', self.on_invite_follower); + this.$el.on('click', '.oe_remove_follower', self.on_remove_follower); + }, + + on_invite_follower: function (event) { + var self = this; + var action = { + type: 'ir.actions.act_window', + res_model: 'mail.wizard.invite', + view_mode: 'form', + view_type: 'form', + views: [[false, 'form']], + target: 'new', + context: { + 'default_res_model': this.view.dataset.model, + 'default_res_id': this.view.datarecord.id, + }, + } + this.do_action(action, { + on_close: function() { + self.read_value(); + }, }); }, + on_remove_follower: function (event) { + var partner_id = $(event.target).data('id'); + var context = new session.web.CompoundContext(this.build_context(), {}); + return this.ds_model.call('message_unsubscribe', [[this.view.datarecord.id], [partner_id], context]) + .then(this.proxy('read_value')); + }, + read_value: function () { var self = this; return this.ds_model.read_ids([this.view.datarecord.id], ['message_follower_ids']).then(function (results) { @@ -151,7 +162,7 @@ openerp_mail_followers = function(session, mail) { var node_user_list = this.$('.oe_follower_list').empty(); this.$('.oe_follower_title').html(this._format_followers(records.length)); // truncate number of displayed followers - truncated = records.splice(0, this.displayed_nb); + var truncated = records.splice(0, this.displayed_nb); _(truncated).each(function (record) { record.avatar_url = mail.ChatterUtils.get_image(self.session, 'res.partner', 'image_small', record.id); $(session.web.qweb.render('mail.followers.partner', {'record': record})).appendTo(node_user_list); diff --git a/addons/mail/static/src/xml/mail_followers.xml b/addons/mail/static/src/xml/mail_followers.xml index 11698c1fb62..377ed527cc1 100644 --- a/addons/mail/static/src/xml/mail_followers.xml +++ b/addons/mail/static/src/xml/mail_followers.xml @@ -31,6 +31,7 @@
+ X