[REF] subscribers inheritance: now override message_get_subscribers_ids, so the read is done in another method, or allow to reuse the user_ids in other methods. It allows to cleany separate having the ids from reading them.
bzr revid: tde@openerp.com-20120420124200-3ictqpdjw1jtdkeo
This commit is contained in:
parent
c4e6874e23
commit
afc63c5a3e
|
@ -829,13 +829,13 @@ class crm_lead(crm_case, osv.osv):
|
||||||
# OpenChatter methods and notifications
|
# OpenChatter methods and notifications
|
||||||
# ----------------------------------------
|
# ----------------------------------------
|
||||||
|
|
||||||
def message_get_subscribers(self, cr, uid, ids, context=None):
|
def message_get_subscribers_ids(self, cr, uid, ids, context=None):
|
||||||
sub_ids = self.message_get_subscribers_ids(cr, uid, ids, context=context)
|
sub_ids = super(crm_lead, self).message_get_subscribers_ids(cr, uid, ids, context=context)
|
||||||
# add salesman to the subscribers
|
# add salesman to the subscribers
|
||||||
for obj in self.browse(cr, uid, ids, context=context):
|
for obj in self.browse(cr, uid, ids, context=context):
|
||||||
if obj.user_id:
|
if obj.user_id:
|
||||||
sub_ids.append(obj.user_id.id)
|
sub_ids.append(obj.user_id.id)
|
||||||
return self.pool.get('res.users').read(cr, uid, sub_ids, context=context)
|
return sub_ids
|
||||||
|
|
||||||
def case_get_note_msg_prefix(self, cr, uid, lead, context=None):
|
def case_get_note_msg_prefix(self, cr, uid, lead, context=None):
|
||||||
if isinstance(lead, (int, long)):
|
if isinstance(lead, (int, long)):
|
||||||
|
|
|
@ -372,13 +372,13 @@ class hr_holidays(osv.osv):
|
||||||
result[obj.id] = hr_manager_group['users']
|
result[obj.id] = hr_manager_group['users']
|
||||||
return result
|
return result
|
||||||
|
|
||||||
def message_get_subscribers(self, cr, uid, ids, context=None):
|
def message_get_subscribers_ids(self, cr, uid, ids, context=None):
|
||||||
sub_ids = self.message_get_subscribers_ids(cr, uid, ids, context=context);
|
sub_ids = super(hr_holidays, self).message_get_subscribers_ids(cr, uid, ids, context=context)
|
||||||
# add the employee and its manager if specified to the subscribed users
|
# add the employee and its manager if specified to the subscribed users
|
||||||
for obj in self.browse(cr, uid, ids, context=context):
|
for obj in self.browse(cr, uid, ids, context=context):
|
||||||
if obj.employee_id.parent_id:
|
if obj.employee_id.parent_id:
|
||||||
sub_ids.append(obj.employee_id.parent_id.user_id.id)
|
sub_ids.append(obj.employee_id.parent_id.user_id.id)
|
||||||
return self.pool.get('res.users').read(cr, uid, sub_ids, context=context)
|
return sub_ids
|
||||||
|
|
||||||
def create_notificate(self, cr, uid, ids, context=None):
|
def create_notificate(self, cr, uid, ids, context=None):
|
||||||
for obj in self.browse(cr, uid, ids, context=context):
|
for obj in self.browse(cr, uid, ids, context=context):
|
||||||
|
|
|
@ -484,12 +484,12 @@ class hr_applicant(crm.crm_case, osv.osv):
|
||||||
# OpenChatter methods and notifications
|
# OpenChatter methods and notifications
|
||||||
# -------------------------------------------------------
|
# -------------------------------------------------------
|
||||||
|
|
||||||
def message_get_subscribers(self, cr, uid, ids, context=None):
|
def message_get_subscribers_ids(self, cr, uid, ids, context=None):
|
||||||
sub_ids = self.message_get_subscribers_ids(cr, uid, ids, context=context);
|
sub_ids = super(hr_applicant, self).message_get_subscribers_ids(cr, uid, ids, context=context)
|
||||||
for obj in self.browse(cr, uid, ids, context=context):
|
for obj in self.browse(cr, uid, ids, context=context):
|
||||||
if obj.user_id:
|
if obj.user_id:
|
||||||
sub_ids.append(obj.user_id.id)
|
sub_ids.append(obj.user_id.id)
|
||||||
return self.pool.get('res.users').read(cr, uid, sub_ids, context=context)
|
return sub_ids
|
||||||
|
|
||||||
def get_needaction_user_ids(self, cr, uid, ids, context=None):
|
def get_needaction_user_ids(self, cr, uid, ids, context=None):
|
||||||
result = dict.fromkeys(ids, [])
|
result = dict.fromkeys(ids, [])
|
||||||
|
|
|
@ -108,7 +108,7 @@ class mail_thread(osv.osv):
|
||||||
# delete subscriptions
|
# delete subscriptions
|
||||||
subscr_to_del_ids = subscr_obj.search(cr, uid, [('res_model', '=', self._name), ('res_id', 'in', ids)], context=context)
|
subscr_to_del_ids = subscr_obj.search(cr, uid, [('res_model', '=', self._name), ('res_id', 'in', ids)], context=context)
|
||||||
subscr_obj.unlink(cr, uid, subscr_to_del_ids, context=context)
|
subscr_obj.unlink(cr, uid, subscr_to_del_ids, context=context)
|
||||||
# delete notifications
|
# delete messages and notifications
|
||||||
msg_to_del_ids = msg_obj.search(cr, uid, [('model', '=', self._name), ('res_id', 'in', ids)], context=context)
|
msg_to_del_ids = msg_obj.search(cr, uid, [('model', '=', self._name), ('res_id', 'in', ids)], context=context)
|
||||||
msg_obj.unlink(cr, uid, msg_to_del_ids, context=context)
|
msg_obj.unlink(cr, uid, msg_to_del_ids, context=context)
|
||||||
|
|
||||||
|
@ -119,7 +119,7 @@ class mail_thread(osv.osv):
|
||||||
#------------------------------------------------------
|
#------------------------------------------------------
|
||||||
|
|
||||||
def message_create(self, cr, uid, thread_id, vals, context=None):
|
def message_create(self, cr, uid, thread_id, vals, context=None):
|
||||||
"""OpenSocial: wrapper of mail.message create method
|
"""OpenChatter: wrapper of mail.message create method
|
||||||
- creates the mail.message
|
- creates the mail.message
|
||||||
- automatically subscribe the message writer
|
- automatically subscribe the message writer
|
||||||
- push the message to subscribed users
|
- push the message to subscribed users
|
||||||
|
@ -182,6 +182,10 @@ class mail_thread(osv.osv):
|
||||||
for thread_id in thread_ids:
|
for thread_id in thread_ids:
|
||||||
# add subscribers
|
# add subscribers
|
||||||
notif_user_ids += [user['id'] for user in self.message_get_subscribers(cr, uid, [thread_id], context=context)]
|
notif_user_ids += [user['id'] for user in self.message_get_subscribers(cr, uid, [thread_id], context=context)]
|
||||||
|
|
||||||
|
# get hiden subscriptions
|
||||||
|
#subscription_hide_obj.search(cr, uid, [('subscription_id', 'in', ids), ('subtype', '=', new_msg_vals.get('subtype'))], context=context)
|
||||||
|
|
||||||
# add users requested via parsing message (@login)
|
# add users requested via parsing message (@login)
|
||||||
notif_user_ids += self.message_parse_users(cr, uid, [thread_id], body, context=context)
|
notif_user_ids += self.message_parse_users(cr, uid, [thread_id], body, context=context)
|
||||||
# add users requested to perform an action (need_action mechanism)
|
# add users requested to perform an action (need_action mechanism)
|
||||||
|
|
|
@ -1041,12 +1041,12 @@ class mrp_production(osv.osv):
|
||||||
result[obj.id] = [obj.user_id.id]
|
result[obj.id] = [obj.user_id.id]
|
||||||
return result
|
return result
|
||||||
|
|
||||||
def message_get_subscribers(self, cr, uid, ids, context=None):
|
def message_get_subscribers_ids(self, cr, uid, ids, context=None):
|
||||||
sub_ids = self.message_get_subscribers_ids(cr, uid, ids, context=context);
|
sub_ids = super(mrp_production, self).message_get_subscribers_ids(cr, uid, ids, context=context)
|
||||||
for obj in self.browse(cr, uid, ids, context=context):
|
for obj in self.browse(cr, uid, ids, context=context):
|
||||||
if obj.user_id:
|
if obj.user_id:
|
||||||
sub_ids.append(obj.user_id.id)
|
sub_ids.append(obj.user_id.id)
|
||||||
return self.pool.get('res.users').read(cr, uid, sub_ids, context=context)
|
return sub_ids
|
||||||
|
|
||||||
def create_send_note(self, cr, uid, ids, context=None):
|
def create_send_note(self, cr, uid, ids, context=None):
|
||||||
self.message_append_note(cr, uid, ids, body=_("Manufacturing order has been <b>created</b>."), context=context)
|
self.message_append_note(cr, uid, ids, body=_("Manufacturing order has been <b>created</b>."), context=context)
|
||||||
|
|
|
@ -455,12 +455,12 @@ def Project():
|
||||||
result[obj.id] = [obj.user_id.id]
|
result[obj.id] = [obj.user_id.id]
|
||||||
return result
|
return result
|
||||||
|
|
||||||
def message_get_subscribers(self, cr, uid, ids, context=None):
|
def message_get_subscribers_ids(self, cr, uid, ids, context=None):
|
||||||
sub_ids = self.message_get_subscribers_ids(cr, uid, ids, context=context);
|
sub_ids = super(project_project, self).message_get_subscribers_ids(cr, uid, ids, context=context);
|
||||||
for obj in self.browse(cr, uid, ids, context=context):
|
for obj in self.browse(cr, uid, ids, context=context):
|
||||||
if obj.user_id:
|
if obj.user_id:
|
||||||
sub_ids.append(obj.user_id.id)
|
sub_ids.append(obj.user_id.id)
|
||||||
return self.pool.get('res.users').read(cr, uid, sub_ids, context=context)
|
return sub_ids
|
||||||
|
|
||||||
def create(self, cr, uid, vals, context=None):
|
def create(self, cr, uid, vals, context=None):
|
||||||
obj_id = super(project, self).create(cr, uid, vals, context=context)
|
obj_id = super(project, self).create(cr, uid, vals, context=context)
|
||||||
|
@ -1138,14 +1138,14 @@ class task(osv.osv):
|
||||||
result[obj.id] = [obj.user_id.id]
|
result[obj.id] = [obj.user_id.id]
|
||||||
return result
|
return result
|
||||||
|
|
||||||
def message_get_subscribers(self, cr, uid, ids, context=None):
|
def message_get_subscribers_ids(self, cr, uid, ids, context=None):
|
||||||
sub_ids = self.message_get_subscribers_ids(cr, uid, ids, context=context);
|
sub_ids = super(project_task, self).message_get_subscribers_ids(cr, uid, ids, context=context)
|
||||||
for obj in self.browse(cr, uid, ids, context=context):
|
for obj in self.browse(cr, uid, ids, context=context):
|
||||||
if obj.user_id:
|
if obj.user_id:
|
||||||
sub_ids.append(obj.user_id.id)
|
sub_ids.append(obj.user_id.id)
|
||||||
if obj.manager_id:
|
if obj.manager_id:
|
||||||
sub_ids.append(obj.manager_id.id)
|
sub_ids.append(obj.manager_id.id)
|
||||||
return self.pool.get('res.users').read(cr, uid, sub_ids, context=context)
|
return sub_ids
|
||||||
|
|
||||||
def create_send_note(self, cr, uid, ids, context=None):
|
def create_send_note(self, cr, uid, ids, context=None):
|
||||||
return self.message_append_note(cr, uid, ids, body=_("Task has been <b>created</b>."), context=context)
|
return self.message_append_note(cr, uid, ids, body=_("Task has been <b>created</b>."), context=context)
|
||||||
|
|
|
@ -474,12 +474,12 @@ class project_issue(crm.crm_case, osv.osv):
|
||||||
result[obj.id] = [obj.user_id.id]
|
result[obj.id] = [obj.user_id.id]
|
||||||
return result
|
return result
|
||||||
|
|
||||||
def message_get_subscribers(self, cr, uid, ids, context=None):
|
def message_get_subscribers_ids(self, cr, uid, ids, context=None):
|
||||||
sub_ids = self.message_get_subscribers_ids(cr, uid, ids, context=context);
|
sub_ids = super(project_issue, self).message_get_subscribers_ids(cr, uid, ids, context=context)
|
||||||
for obj in self.browse(cr, uid, ids, context=context):
|
for obj in self.browse(cr, uid, ids, context=context):
|
||||||
if obj.user_id:
|
if obj.user_id:
|
||||||
sub_ids.append(obj.user_id.id)
|
sub_ids.append(obj.user_id.id)
|
||||||
return self.pool.get('res.users').read(cr, uid, sub_ids, context=context)
|
return sub_ids
|
||||||
|
|
||||||
def case_get_note_msg_prefix(self, cr, uid, id, context=None):
|
def case_get_note_msg_prefix(self, cr, uid, id, context=None):
|
||||||
return 'Project issue '
|
return 'Project issue '
|
||||||
|
|
Loading…
Reference in New Issue