[IMP] mail: all email checked create a partner and associate the email from

bzr revid: chm@openerp.com-20130108134424-dthns93bf0w59juf
This commit is contained in:
Christophe Matthieu 2013-01-08 14:44:24 +01:00
parent 9c5fad41ba
commit 10b92b71d8
1 changed files with 6 additions and 6 deletions

View File

@ -921,19 +921,19 @@ class mail_thread(osv.AbstractModel):
email = m.group(3)
ids = partner_obj.search(cr, SUPERUSER_ID, [('email', '=', email)], context=context)
if ids:
partner_ids += ids
partner_id = ids[0]
partner_ids.append(partner_id)
else:
partner_id = partner_obj.create(cr, uid, {
'name': name or email,
'email': email,
}, context=context)
new_partner_ids.append(partner_id)
# link mail with this from mail to the new partner id
message_ids = mail_message_obj.search(cr, SUPERUSER_ID, ['|', ('email_from', '=', email), ('email_from', 'ilike', '<%s>' % email), ('author_id', '=', False)], context=context)
if message_ids:
mail_message_obj.write(cr, SUPERUSER_ID, message_ids, {'email_from': None, 'author_id': partner_id}, context=context)
# link mail with this from mail to the new partner id
message_ids = mail_message_obj.search(cr, SUPERUSER_ID, ['|', ('email_from', '=', email), ('email_from', 'ilike', '<%s>' % email), ('author_id', '=', False)], context=context)
if message_ids:
mail_message_obj.write(cr, SUPERUSER_ID, message_ids, {'email_from': None, 'author_id': partner_id}, context=context)
return {
'partner_ids': partner_ids,
'new_partner_ids': new_partner_ids,