diff --git a/addons/mail/mail_group_view.xml b/addons/mail/mail_group_view.xml index 31beba80ecc..bac7c22ee09 100644 --- a/addons/mail/mail_group_view.xml +++ b/addons/mail/mail_group_view.xml @@ -81,6 +81,7 @@
+ diff --git a/addons/mail/mail_thread.py b/addons/mail/mail_thread.py index 6b4db7bc7d1..ea6f795bc61 100644 --- a/addons/mail/mail_thread.py +++ b/addons/mail/mail_thread.py @@ -119,7 +119,7 @@ class mail_thread(osv.AbstractModel): def _get_message_data(self, cr, uid, ids, name, args, context=None): res = dict((id, dict(message_unread=False, message_summary='')) for id in ids) - user = self.pool.get('res.users').browse(cr, uid, uid, context=context) + partner_id = self.pool.get('res.users').read(cr, uid, uid, ['partner_id'], context=context)['partner_id'][0] # search for unread messages, by reading directly mail.notification, as SUPERUSER notif_obj = self.pool.get('mail.notification') @@ -132,10 +132,10 @@ class mail_thread(osv.AbstractModel): for notif in notif_obj.browse(cr, SUPERUSER_ID, notif_ids, context=context): res[notif.message_id.res_id]['message_unread'] = True - for thread in self.browse(cr, uid, ids, context=context): - cls = res[thread.id]['message_unread'] and ' class="oe_kanban_mail_new"' or '' - res[thread.id]['message_summary'] = "9 %d + %d" % (cls, len(thread.message_comment_ids), len(thread.message_follower_ids)) - res[thread.id]['message_is_follower'] = user.partner_id.id in [follower.id for follower in thread.message_follower_ids] + for thread in self.read(cr, uid, ids, ['message_follower_ids', 'message_comment_ids', 'message_ids'], context=context): + cls = res[thread['id']]['message_unread'] and ' class="oe_kanban_mail_new"' or '' + res[thread['id']]['message_summary'] = "9 %d + %d" % (cls, len(thread['message_comment_ids']), len(thread['message_follower_ids'])) + res[thread['id']]['message_is_follower'] = partner_id in thread['message_follower_ids'] return res def _search_unread(self, cr, uid, obj=None, name=None, domain=None, context=None): diff --git a/addons/mail/static/src/js/mail_followers.js b/addons/mail/static/src/js/mail_followers.js index cf33bd64640..c3c59428920 100644 --- a/addons/mail/static/src/js/mail_followers.js +++ b/addons/mail/static/src/js/mail_followers.js @@ -88,7 +88,24 @@ openerp_mail_followers = function(session, mail) { }, fetch_followers: function (value_) { - return this.ds_follow.call('read', [value_, ['name', 'user_ids']]).pipe(this.proxy('display_followers')); + this.value = value_; + this.message_is_follower = this.getParent().fields.message_is_follower && this.getParent().fields.message_is_follower.get_value() || undefined; + return this.ds_follow.call('read', [value_, ['name', 'user_ids']]).pipe(this.proxy('display_followers'), this.proxy('display_generic')); + }, + + + /* Display generic info about follower, for people not having access to res_partner */ + display_generic: function (error, event) { + event.preventDefault(); + var node_user_list = this.$el.find('ul.oe_mail_followers_display').empty(); + this.$el.find('div.oe_mail_recthread_followers h4').html(this.options.title + ' (' + this.value.length + ')'); + if (this.message_is_follower) { + this.$el.find('button.oe_mail_button_follow').hide(); + this.$el.find('button.oe_mail_button_unfollow').show(); } + else { + this.$el.find('button.oe_mail_button_follow').show(); + this.$el.find('button.oe_mail_button_unfollow').hide(); } + return $.when(); }, /** Display the followers, evaluate is_follower directly */