[FIX] mail/followers: set partner_id of uid on the root thread; No set_value in followers widget
bzr revid: chm@openerp.com-20121108153327-wopb6dscgnf1t4wp
This commit is contained in:
parent
b028b74ed0
commit
df1403d9b6
|
@ -178,7 +178,7 @@ openerp.mail = function (session) {
|
|||
this.is_favorite = datasets.is_favorite || false,
|
||||
this.thread_level = datasets.thread_level || 0,
|
||||
this.to_read = datasets.to_read || false,
|
||||
this.author_id = datasets.author_id || [this.session.uid],
|
||||
this.author_id = datasets.author_id || [this.options.root_thread.pid],
|
||||
this.attachment_ids = datasets.attachment_ids || [],
|
||||
this.partner_ids = datasets.partner_ids || [];
|
||||
this._date = datasets.date;
|
||||
|
@ -1424,6 +1424,7 @@ openerp.mail = function (session) {
|
|||
*/
|
||||
init: function (parent, action) {
|
||||
this._super(parent, action);
|
||||
var self = this;
|
||||
this.action = _.clone(action);
|
||||
this.domain = this.action.domain || this.action.params.domain || [];
|
||||
this.context = this.action.context || this.action.params.context || {};
|
||||
|
@ -1441,6 +1442,11 @@ openerp.mail = function (session) {
|
|||
}, this.action.params);
|
||||
|
||||
this.action.params.help = this.action.help || false;
|
||||
|
||||
new session.web.DataSetSearch(this, 'res.users').call('read', [this.session.uid, ['partner_id']])
|
||||
.then(function (result) {
|
||||
self.session.partner_id = result.partner_id || false;
|
||||
});
|
||||
},
|
||||
|
||||
start: function (options) {
|
||||
|
|
|
@ -30,6 +30,8 @@ openerp_mail_followers = function(session, mail) {
|
|||
this.ds_model = new session.web.DataSetSearch(this, this.view.model);
|
||||
this.ds_follow = new session.web.DataSetSearch(this, this.field.relation);
|
||||
this.ds_users = new session.web.DataSetSearch(this, 'res.users');
|
||||
|
||||
this.value = [];
|
||||
},
|
||||
|
||||
start: function() {
|
||||
|
@ -41,6 +43,11 @@ openerp_mail_followers = function(session, mail) {
|
|||
this._super();
|
||||
},
|
||||
|
||||
set_value: function(_value) {
|
||||
this.value = _value;
|
||||
this._super(_value);
|
||||
},
|
||||
|
||||
_check_visibility: function() {
|
||||
this.$el.toggle(this.view.get("actual_mode") !== "create");
|
||||
},
|
||||
|
@ -86,13 +93,14 @@ openerp_mail_followers = function(session, mail) {
|
|||
read_value: function () {
|
||||
var self = this;
|
||||
return this.ds_model.read_ids([this.view.datarecord.id], ['message_follower_ids']).then(function (results) {
|
||||
self.set_value(results[0].message_follower_ids);
|
||||
self.value = results[0].message_follower_ids;
|
||||
self.render_value();
|
||||
});
|
||||
},
|
||||
|
||||
render_value: function () {
|
||||
this.reinit();
|
||||
return this.fetch_followers(this.get("value"));
|
||||
return this.fetch_followers(this.value);
|
||||
},
|
||||
|
||||
fetch_followers: function (value_) {
|
||||
|
@ -111,7 +119,7 @@ openerp_mail_followers = function(session, mail) {
|
|||
event.preventDefault();
|
||||
return this.ds_users.call('read', [this.session.uid, ['partner_id']]).then(function (results) {
|
||||
var pid = results['partner_id'][0];
|
||||
self.message_is_follower = (_.indexOf(self.get('value'), pid) != -1);
|
||||
self.message_is_follower = (_.indexOf(self.value, pid) != -1);
|
||||
}).then(self.proxy('display_generic'));
|
||||
},
|
||||
_format_followers: function(count){
|
||||
|
@ -131,7 +139,7 @@ openerp_mail_followers = function(session, mail) {
|
|||
display_generic: function () {
|
||||
var self = this;
|
||||
var node_user_list = this.$('.oe_follower_list').empty();
|
||||
this.$('.oe_follower_title').html(this._format_followers(this.get('value').length));
|
||||
this.$('.oe_follower_title').html(this._format_followers(this.value.length));
|
||||
},
|
||||
|
||||
/** Display the followers */
|
||||
|
@ -206,7 +214,8 @@ openerp_mail_followers = function(session, mail) {
|
|||
$(record).attr('checked',false);
|
||||
});
|
||||
var context = new session.web.CompoundContext(this.build_context(), {});
|
||||
return this.ds_model.call('message_unsubscribe_users', [[this.view.datarecord.id], [this.session.uid], context]).then(this.proxy('read_value'));
|
||||
return this.ds_model.call('message_unsubscribe_users', [[this.view.datarecord.id], [this.session.uid], context])
|
||||
.then(this.proxy('read_value'));
|
||||
},
|
||||
|
||||
do_update_subscription: function (event) {
|
||||
|
@ -220,7 +229,7 @@ openerp_mail_followers = function(session, mail) {
|
|||
});
|
||||
|
||||
var context = new session.web.CompoundContext(this.build_context(), {});
|
||||
return this.ds_model.call('message_subscribe_users', [[this.view.datarecord.id], [this.session.uid], this.message_is_follower ? checklist:undefined, context])
|
||||
return this.ds_model.call('message_subscribe_users', [[this.view.datarecord.id], [this.session.uid], this.message_is_follower ? checklist : undefined, context])
|
||||
.then(this.proxy('read_value'));
|
||||
},
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue