@ -1470,6 +1470,7 @@ class mail_thread(osv.AbstractModel):
: param boolean check_followers : check in document followers
"""
partner_obj = self . pool [ ' res.partner ' ]
users_obj = self . pool [ ' res.users ' ]
partner_ids = [ ]
obj = None
if id and ( model or self . _name != ' mail.thread ' ) and check_followers :
@ -1495,16 +1496,15 @@ class mail_thread(osv.AbstractModel):
email_brackets = " < %s > " % email_address
if not partner_id :
# exact, case-insensitive match
ids = partner_obj . search ( cr , SUPERUSER_ID ,
[ ( ' email ' , ' =ilike ' , email_address ) ,
( ' user_ids ' , ' != ' , False ) ] ,
user_ids = users_obj . search ( cr , SUPERUSER_ID ,
[ ( ' email ' , ' =ilike ' , email_address ) ] ,
limit = 1 , context = context )
ids = [ users_obj . browse ( cr , SUPERUSER_ID , user_ids , context = context ) . partner_id . id ]
if not ids :
# if no match with addr-spec, attempt substring match within name-addr pair
ids = partner_obj . search ( cr , SUPERUSER_ID ,
[ ( ' email ' , ' ilike ' , email_brackets ) ,
( ' user_ids ' , ' != ' , False ) ] ,
limit = 1 , context = context )
user_ids = users_obj . search ( cr , SUPERUSER_ID ,
[ ( ' email ' , ' ilike ' , email_brackets ) ] , limit = 1 , context = context )
ids = [ users_obj . browse ( cr , SUPERUSER_ID , user_ids , context = context ) . partner_id . id ]
if ids :
partner_id = ids [ 0 ]
# third try: check in partners