diff --git a/addons/mail/mail_group_view.xml b/addons/mail/mail_group_view.xml
index b74c154d9cf..9facf51febe 100644
--- a/addons/mail/mail_group_view.xml
+++ b/addons/mail/mail_group_view.xml
@@ -83,7 +83,7 @@
+ context="{'lapin': 'nouille'}" image="image_small"/>
diff --git a/addons/mail/mail_thread.py b/addons/mail/mail_thread.py
index 7ef74641d77..cf33e64dd79 100644
--- a/addons/mail/mail_thread.py
+++ b/addons/mail/mail_thread.py
@@ -965,7 +965,8 @@ class mail_thread(osv.Model):
uid instead
"""
to_subscribe_uids = [uid] if user_ids is None else user_ids
- return self.write(cr, uid, ids, {'message_subscriber_ids': [(4, id) for id in to_subscribe_uids]}, context=context)
+ write_res = self.write(cr, uid, ids, {'message_subscriber_ids': [(4, id) for id in to_subscribe_uids]}, context=context)
+ return [follower.id for thread in self.browse(cr, uid, ids, context=context) for follower in thread.message_subscriber_ids]
def message_unsubscribe(self, cr, uid, ids, user_ids = None, context=None):
""" Unsubscribe the user (or user_ids) from the current document.
@@ -974,7 +975,8 @@ class mail_thread(osv.Model):
uid instead
"""
to_unsubscribe_uids = [uid] if user_ids is None else user_ids
- return self.write(cr, uid, ids, {'message_subscriber_ids': [(3, id) for id in to_unsubscribe_uids]}, context=context)
+ write_res = self.write(cr, uid, ids, {'message_subscriber_ids': [(3, id) for id in to_unsubscribe_uids]}, context=context)
+ return [follower.id for thread in self.browse(cr, uid, ids, context=context) for follower in thread.message_subscriber_ids]
#------------------------------------------------------
# Notification API
diff --git a/addons/mail/static/src/js/mail_followers.js b/addons/mail/static/src/js/mail_followers.js
index b4b8a6e9797..30d83667165 100644
--- a/addons/mail/static/src/js/mail_followers.js
+++ b/addons/mail/static/src/js/mail_followers.js
@@ -22,25 +22,24 @@ openerp_mail_followers = function(session, mail) {
init: function() {
this._super.apply(this, arguments);
- this.params = this.get_definition_options();
- this.params.see_subscribers = true;
- this.params.see_subscribers_options = this.params.see_subscribers_options || false;
- this.ds = new session.web.DataSetSearch(this, this.view.model);
- this.ds_users = new session.web.DataSetSearch(this, 'res.users');
-
+ debugger
+ this.params = {};
+ this.params.image = this.node.attrs.image || 'image_small';
+ this.params.display_followers = true;
+ this.params.display_control = this.node.attrs.display_control || false;
+ this.params.display_actions = this.node.attrs.display_actions || false;
+ this.ds_model = new session.web.DataSetSearch(this, this.view.model);
+ this.ds_follow = new session.web.DataSetSearch(this, this.field.relation);
},
start: function() {
var self = this;
-
// NB: all the widget should be modified to check the actual_mode property on view, not use
// any other method to know if the view is in create mode anymore
this.view.on("change:actual_mode", this, this._check_visibility);
this._check_visibility();
-
- // session.mail.ChatterUtils.bind_events(this);
this.$element.find('button.oe_mail_button_followers').click(function () { self.do_toggle_followers(); });
- if (! this.params.see_subscribers_options) {
+ if (! this.params.display_control) {
this.$element.find('button.oe_mail_button_followers').hide(); }
this.$element.find('button.oe_mail_button_follow').click(function () { self.do_follow(); })
.mouseover(function () { $(this).html('Follow').removeClass('oe_mail_button_mouseout').addClass('oe_mail_button_mouseover'); })
@@ -60,16 +59,15 @@ openerp_mail_followers = function(session, mail) {
},
reinit: function() {
- this.params.see_subscribers = true;
- this.params.see_subscribers_options = this.params.see_subscribers_options || false;
+ this.params.display_followers = true;
+ this.params.display_control = this.node.attrs.display_control || false;
+ this.params.display_actions = this.node.attrs.display_actions || false;
this.$element.find('button.oe_mail_button_followers').html('Hide followers')
this.$element.find('button.oe_mail_button_follow').hide();
this.$element.find('button.oe_mail_button_unfollow').hide();
},
set_value: function(value_) {
- console.log(value_);
- // debugger
this.reinit();
if (! this.view.datarecord.id ||
session.web.BufferedDataSet.virtual_id_regex.test(this.view.datarecord.id)) {
@@ -80,7 +78,7 @@ openerp_mail_followers = function(session, mail) {
},
fetch_subscribers: function (value_) {
- return this.ds_users.call('read', [value_ || this.get_value(), ['name', 'image_small']]).then(this.proxy('display_subscribers'));
+ return this.ds_follow.call('read', [value_ || this.get_value(), ['name', this.params.image]]).then(this.proxy('display_subscribers'));
},
display_subscribers: function (records) {
@@ -102,17 +100,12 @@ openerp_mail_followers = function(session, mail) {
},
do_follow: function () {
- return this.ds.call('message_subscribe', [[this.view.datarecord.id]]).pipe(this.proxy('fetch_subscribers'));
+ return this.ds_model.call('message_subscribe', [[this.view.datarecord.id]]).pipe(this.proxy('set_value'));
},
do_unfollow: function () {
var self = this;
- return this.ds.call('message_unsubscribe', [[this.view.datarecord.id]]).pipe(function (record) {
- // debugger
- var new_value = self.view.datarecord.message_subscriber_ids;
- // return [new_value.splice(_.indexOf(new_value, self.session.uid, true), 1);]
- return [2]
- }).pipe(this.proxy('set_value'));
+ return this.ds_model.call('message_unsubscribe', [[this.view.datarecord.id]]).pipe(this.proxy('set_value'));
},
do_toggle_followers: function () {