[IMP][FIX] creating and updating a record automatically subscribe the user. Fixed message_is_subscriber not calling message_get_subscribers, leading to wrong calculation when message_get_subscribers was overwriten.
bzr revid: tde@openerp.com-20120228140632-jd27456g1e9fu056
This commit is contained in:
@@ -68,6 +68,21 @@ class mail_thread(osv.osv):
|
||||
),
|
||||
#widget='mail.ThreadView'),
|
||||
}
|
||||
|
||||
#------------------------------------------------------
|
||||
# Automatic subscription when creating/reading
|
||||
#------------------------------------------------------
|
||||
|
||||
def create(self, cr, uid, vals, context=None):
|
||||
thread_id = super(mail_thread, self).create(cr, uid, vals, context=context);
|
||||
self.message_subscribe(cr, uid, [thread_id], [uid], context=context)
|
||||
return thread_id;
|
||||
|
||||
def write(self, cr, uid, ids, vals, context=None):
|
||||
write_res = super(mail_thread, self).write(cr, uid, ids, vals, context=context);
|
||||
if write_res:
|
||||
self.message_subscribe(cr, uid, ids, [uid], context=context)
|
||||
return write_res;
|
||||
|
||||
#------------------------------------------------------
|
||||
# Generic message api
|
||||
@@ -598,13 +613,10 @@ class mail_thread(osv.osv):
|
||||
return users
|
||||
|
||||
def message_is_subscriber(self, cr, uid, ids, context=None):
|
||||
# TODO: use message_get_subscribers ? as all subscriptions are in mail.subscription table, not necessary
|
||||
subscription_obj = self.pool.get('mail.subscription')
|
||||
sub_ids = subscription_obj.search(cr, uid,
|
||||
['&', '&', ('res_model', '=', self._name), ('res_id', 'in', ids), ('user_id', '=', uid)], context=context)
|
||||
if len(sub_ids) > 1:
|
||||
pass # TODO
|
||||
return True if sub_ids else False
|
||||
users = self.message_get_subscribers(cr, uid, ids, context=context)
|
||||
if uid in [user['id'] for user in users]:
|
||||
return True
|
||||
return False
|
||||
|
||||
def message_subscribe(self, cr, uid, ids, user_ids = None, context=None):
|
||||
subscription_obj = self.pool.get('mail.subscription')
|
||||
|
||||
Reference in New Issue
Block a user