[IMP] mail_thread: res_users do not inherit from mail.thread anymore. Moved the search_domain of chatter of res.users (@login) to the partner, that have to find its related partner.
bzr revid: tde@openerp.com-20120814164817-8mw4txrmvka484wg
This commit is contained in:
parent
aac03b547d
commit
40e2dbbab2
|
@ -29,11 +29,21 @@ class res_partner_mail(osv.osv):
|
|||
|
||||
def message_search_get_domain(self, cr, uid, ids, context=None):
|
||||
""" Override of message_search_get_domain for partner discussion page.
|
||||
The purpose is to add messages directly sent to the partner.
|
||||
The purpose is to add messages directly sent to the partner. It also
|
||||
adds messages pushed to the related user, if any, using @login.
|
||||
"""
|
||||
initial_domain = super(res_partner_mail, self).message_search_get_domain(cr, uid, ids, context=context)
|
||||
if self._name == 'res.partner': # to avoid models inheriting from res.partner
|
||||
search_domain = ['|'] + initial_domain + ['|', ('partner_id', 'in', ids), ('partner_ids', 'in', ids)]
|
||||
# to avoid models inheriting from res.partner
|
||||
if self._name != 'res.partner':
|
||||
return initial_domain
|
||||
# add message linked to the partner
|
||||
search_domain = ['|'] + initial_domain + ['|', ('partner_id', 'in', ids), ('partner_ids', 'in', ids)]
|
||||
# if partner is linked to a user: find @login
|
||||
res_users_obj = self.pool.get('res.users')
|
||||
user_ids = res_users_obj.search(cr, uid, [('partner_id', 'in', ids)], context=context)
|
||||
for user in res_user_obj.browse(cr, uid, user_ids, context=context):
|
||||
search_domain = ['|'] + search_domain + ['|', ('body_text', 'like', '@%s' % (user.login)), ('body_html', 'like', '@%s' % (user.login))]
|
||||
print search_domain
|
||||
return search_domain
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
|
|
|
@ -143,28 +143,12 @@ To setup your preferences (name, email signature, avatar), click on the top righ
|
|||
email_cc=None, email_bcc=None, reply_to=None,
|
||||
headers=None, message_id=False, references=None,
|
||||
attachments=None, original=None, context=None):
|
||||
""" Override of message_append. Messages appened to res.users are
|
||||
redirected to the related partner. Using partner_id.message_append,
|
||||
messages will have correct model and id, set to res_partner and
|
||||
partner_id.id.
|
||||
"""
|
||||
""" Wrapper on message_append to redirect them to the related partner. """
|
||||
for user in self.browse(cr, uid, threads, context=context):
|
||||
user.partner_id.message_append(subject, body_text, body_html, type, email_date, parent_id,
|
||||
content_subtype, state, partner_ids, email_from, email_to, email_cc, email_bcc, reply_to,
|
||||
headers, message_id, references, attachments, original)
|
||||
|
||||
def message_search_get_domain(self, cr, uid, ids, context=None):
|
||||
""" Override of message_search_get_domain for partner discussion page.
|
||||
The purpose is to add messages directly sent to user using
|
||||
@user_login.
|
||||
"""
|
||||
initial_domain = super(res_users, self).message_search_get_domain(cr, uid, ids, context=context)
|
||||
custom_domain = []
|
||||
for user in self.browse(cr, uid, ids, context=context):
|
||||
if custom_domain:
|
||||
custom_domain += ['|']
|
||||
custom_domain += ['|', ('body_text', 'like', '@%s' % (user.login)), ('body_html', 'like', '@%s' % (user.login))]
|
||||
return ['|'] + initial_domain + custom_domain
|
||||
|
||||
class res_users_mail_group(osv.osv):
|
||||
""" Update of res.groups class
|
||||
|
@ -173,7 +157,7 @@ class res_users_mail_group(osv.osv):
|
|||
group. This is done by overriding the write method.
|
||||
"""
|
||||
_name = 'res.users'
|
||||
_inherit = ['res.users', 'mail.thread']
|
||||
_inherit = ['res.users']
|
||||
|
||||
def write(self, cr, uid, ids, vals, context=None):
|
||||
write_res = super(res_users_mail_group, self).write(cr, uid, ids, vals, context=context)
|
||||
|
|
Loading…
Reference in New Issue