[FIX] Mailboxes: now post on res.users, with correct uid. Posts on res.users usign message_post_api are redirected to the related partner.
bzr revid: tde@openerp.com-20121017143335-xxgfe1fsqqwz2gon
This commit is contained in:
parent
5731a2a46c
commit
3c7efc0de5
|
@ -324,7 +324,7 @@ class mail_message(osv.Model):
|
|||
# TDE note: should not receive [None] !!
|
||||
if ids and ids != [None]:
|
||||
for message in self.read(cr, uid, ids, self._message_read_fields, context=context):
|
||||
message_list.append(self._message_dict_get(cr, uid, message, context=context))
|
||||
message_list.append(self._message_get_dict(cr, uid, message, context=context))
|
||||
return message_list
|
||||
|
||||
# key: ID, value: record
|
||||
|
|
|
@ -88,21 +88,21 @@
|
|||
<field name="name">Inbox</field>
|
||||
<field name="tag">mail.wall</field>
|
||||
<field name="params" eval=""{'domain': [('notification_ids.partner_id.user_ids', 'in', [uid]),('unread', '=', True)],
|
||||
'context': {'default_model': 'res.partner'} }""/>
|
||||
'context': {'default_model': 'res.users', 'default_res_id': uid} }""/>
|
||||
</record>
|
||||
|
||||
<record id="action_mail_archives_feeds" model="ir.actions.client">
|
||||
<field name="name">Archives</field>
|
||||
<field name="tag">mail.wall</field>
|
||||
<field name="params" eval=""{'domain': [('notification_ids.partner_id.user_ids', 'in', [uid]),('unread', '=', False)],
|
||||
'context': {'default_model': 'res.partner'} }""/>
|
||||
'context': {'default_model': 'res.users', 'default_res_id': uid} }""/>
|
||||
</record>
|
||||
|
||||
<record id="action_mail_sent_feeds" model="ir.actions.client">
|
||||
<field name="name">Sent</field>
|
||||
<field name="tag">mail.wall</field>
|
||||
<field name="params" eval=""{'domain': [('author_id.user_ids', 'in', [uid])],
|
||||
'context': {'default_model': 'res.partner'} }""/>
|
||||
'context': {'default_model': 'res.users', 'default_res_id': uid} }""/>
|
||||
</record>
|
||||
</data>
|
||||
</openerp>
|
||||
|
|
|
@ -99,7 +99,8 @@ class res_users(osv.Model):
|
|||
|
||||
def write(self, cr, uid, ids, vals, context=None):
|
||||
# User alias is sync'ed with login
|
||||
if vals.get('login'): vals['alias_name'] = vals['login']
|
||||
if vals.get('login'):
|
||||
vals['alias_name'] = vals['login']
|
||||
return super(res_users, self).write(cr, uid, ids, vals, context=context)
|
||||
|
||||
def unlink(self, cr, uid, ids, context=None):
|
||||
|
@ -110,14 +111,20 @@ class res_users(osv.Model):
|
|||
alias_pool.unlink(cr, uid, alias_ids, context=context)
|
||||
return res
|
||||
|
||||
def message_post(self, cr, uid, thread_id, context=None, **kwargs):
|
||||
def message_post_api(self, cr, uid, thread_id, body='', subject=False, type='notification',
|
||||
subtype=None, parent_id=False, attachments=None, context=None, **kwargs):
|
||||
""" Redirect the posting of message on res.users to the related partner.
|
||||
This is done because when giving the context of Chatter on the
|
||||
various mailboxes, we do not have access to the current partner_id.
|
||||
We therefore post on the user and redirect on its partner. """
|
||||
assert thread_id, "res.users does not support posting global messages"
|
||||
if context and 'thread_model' in context:
|
||||
context['thread_model'] = 'res.partner'
|
||||
if isinstance(thread_id, (list, tuple)):
|
||||
thread_id = thread_id[0]
|
||||
partner_id = self.pool.get('res.users').read(cr, uid, thread_id, ['partner_id'], context=context)['partner_id'][0]
|
||||
return self.pool.get('res.partner').message_post(cr, uid, partner_id, context=context, **kwargs)
|
||||
return self.pool.get('res.partner').message_post_api(cr, uid, partner_id, body=body, subject=subject,
|
||||
type=type, subtype=subtype, parent_id=parent_id, attachments=attachments, context=context, **kwargs)
|
||||
|
||||
def message_update(self, cr, uid, ids, msg_dict, update_vals=None, context=None):
|
||||
partner_id = self.pool.get('res.users').browse(cr, uid, ids)[0].partner_id.id
|
||||
|
|
Loading…
Reference in New Issue