[IMP] Improved code and passed user_id=None as optional field.
bzr revid: psa@tinyerp.com-20130405134425-3xfbbv3vapq1un68
This commit is contained in:
@@ -112,7 +112,7 @@ class mail_thread(osv.AbstractModel):
|
||||
res[id]['message_summary'] = "<span class='oe_kanban_mail_new' title='%s'><span class='oe_e'>9</span> %d %s</span>" % (title, res[id].pop('message_unread_count'), _("New"))
|
||||
return res
|
||||
|
||||
def _get_subscription_data(self, cr, uid, ids, user_id, name, args, context=None):
|
||||
def _get_subscription_data(self, cr, uid, ids, name, args, user_id=None, context=None):
|
||||
""" Computes:
|
||||
- message_subtype_data: data about document subtypes: which are
|
||||
available, which are followed if any """
|
||||
@@ -1105,17 +1105,17 @@ class mail_thread(osv.AbstractModel):
|
||||
|
||||
def message_get_subscription_data(self, cr, uid, ids, user_id=None, context=None):
|
||||
""" Wrapper to get subtypes data. """
|
||||
return self._get_subscription_data(cr, uid, ids, user_id, None, None, context=context)
|
||||
return self._get_subscription_data(cr, uid, ids, None, None, user_id=user_id, context=context)
|
||||
|
||||
def message_subscribe_users(self, cr, uid, ids, user_ids=None, partner_id=None, subtype_ids=None, context=None):
|
||||
def message_subscribe_users(self, cr, uid, ids, user_ids=None, subtype_ids=None, user_id=None, context=None):
|
||||
""" Wrapper on message_subscribe, using users. If user_ids is not
|
||||
provided, subscribe uid instead. """
|
||||
if user_ids is None:
|
||||
user_ids = [uid]
|
||||
partner_ids = [user.partner_id.id for user in self.pool.get('res.users').browse(cr, uid, user_ids, context=context)]
|
||||
return self.message_subscribe(cr, uid, ids, partner_ids, partner_id, subtype_ids=subtype_ids, context=context)
|
||||
return self.message_subscribe(cr, uid, ids, partner_ids, subtype_ids=subtype_ids, user_id=user_id, context=context)
|
||||
|
||||
def message_subscribe(self, cr, uid, ids, partner_ids, user_id, subtype_ids=None, context=None):
|
||||
def message_subscribe(self, cr, uid, ids, partner_ids, subtype_ids=None, user_id=None, context=None):
|
||||
""" Add partners to the records followers. """
|
||||
user_pid = self.pool.get('res.users').read(cr, uid, uid, ['partner_id'], context=context)['partner_id'][0]
|
||||
if user_id:
|
||||
|
||||
@@ -264,7 +264,7 @@ openerp_mail_followers = function(session, mail) {
|
||||
|
||||
do_follow: function () {
|
||||
var context = new session.web.CompoundContext(this.build_context(), {});
|
||||
this.ds_model.call('message_subscribe_users', [[this.view.datarecord.id], [this.session.uid], undefined, context])
|
||||
this.ds_model.call('message_subscribe_users', [[this.view.datarecord.id], [this.session.uid], undefined, undefined, context])
|
||||
.then(this.proxy('read_value'));
|
||||
|
||||
_.each(this.$('.oe_subtype_list input'), function (record) {
|
||||
@@ -288,19 +288,15 @@ openerp_mail_followers = function(session, mail) {
|
||||
var self = this;
|
||||
|
||||
var checklist = new Array();
|
||||
if (partner_id) {
|
||||
_($('.oe_edit_actions input[type="checkbox"]')).each(function (record) {
|
||||
if ($(record).is(':checked')) {
|
||||
checklist.push(parseInt($(record).data('id')));
|
||||
}
|
||||
});
|
||||
} else {
|
||||
_(this.$('.oe_actions input[type="checkbox"]')).each(function (record) {
|
||||
if ($(record).is(':checked')) {
|
||||
checklist.push(parseInt($(record).data('id')));
|
||||
}
|
||||
});
|
||||
}
|
||||
var subtype_checkbox = _(this.$('.oe_actions input[type="checkbox"]'))
|
||||
if (partner_id) {
|
||||
subtype_checkbox = _($('.oe_edit_actions input[type="checkbox"]'))
|
||||
}
|
||||
subtype_checkbox.each(function (record) {
|
||||
if ($(record).is(':checked')) {
|
||||
checklist.push(parseInt($(record).data('id')));
|
||||
}
|
||||
});
|
||||
if (!checklist.length) {
|
||||
if (!this.do_unfollow()) {
|
||||
$(event.target).attr("checked", "checked");
|
||||
|
||||
Reference in New Issue
Block a user