summaryrefslogtreecommitdiff
path: root/addons/plugin/plugin_handler.py
diff options
context:
space:
mode:
Diffstat (limited to 'addons/plugin/plugin_handler.py')
-rw-r--r--addons/plugin/plugin_handler.py15
1 files changed, 8 insertions, 7 deletions
diff --git a/addons/plugin/plugin_handler.py b/addons/plugin/plugin_handler.py
index e92abbc3812..94948d015c5 100644
--- a/addons/plugin/plugin_handler.py
+++ b/addons/plugin/plugin_handler.py
@@ -4,7 +4,6 @@ Created on 18 oct. 2011
@author: openerp
'''
-from openerp import tools
from openerp.osv import osv
from openerp.tools.translate import _
@@ -94,7 +93,8 @@ class plugin_handler(osv.osv_memory):
"""
mail_message = self.pool.get('mail.message')
model_obj = self.pool.get(model)
- msg = self.pool.get('mail.thread').message_parse(cr, uid, email)
+ mail_thread_obj = self.pool.get('mail.thread')
+ msg = mail_thread_obj.message_parse(cr, uid, email)
message_id = msg.get('message_id')
mail_ids = mail_message.search(cr, uid, [('message_id', '=', message_id), ('res_id', '=', res_id), ('model', '=', model)])
if message_id and mail_ids:
@@ -108,8 +108,9 @@ class plugin_handler(osv.osv_memory):
res_id = model_obj.message_process(cr, uid, model, email)
notify = _("Mail successfully pushed, a new %s has been created.") % model
else:
- email_from = msg.get('email_from') and tools.email_split(msg.get('email_from')) or False
- author_ids = email_from and self.pool.get('res.partner').search(cr, uid, [('email', 'ilike', email_from[0])], limit=1) or False
+ email_from = msg.get('email_from')
+ author_id = False if not email_from else \
+ mail_thread_obj.message_find_partner_from_emails(cr, uid, [res_id], [email_from])[0].get('partner_id')
model_obj.message_post(cr, uid, [res_id],
body=msg.get('body'),
subject=msg.get('subject'),
@@ -117,8 +118,8 @@ class plugin_handler(osv.osv_memory):
parent_id=msg.get('parent_id'),
attachments=msg.get('attachments'),
message_id=message_id,
- email_from=msg.get('email_from'),
- author_id=author_ids and author_ids[0])
+ email_from=email_from,
+ author_id=author_id)
notify = _("Mail successfully pushed")
url = self._make_url(cr, uid, res_id, model)
return (model, res_id, url, notify)
@@ -171,6 +172,6 @@ class plugin_handler(osv.osv_memory):
attach_ids.append(ir_attachment_obj.create(cr, uid, vals))
mail_ids = mail_message.search(cr, uid, [('message_id', '=', message_id), ('res_id', '=', res_id), ('model', '=', model)])
if mail_ids:
- mail_message.write(cr, uid, mail_ids[0], {'attachment_ids': [(6, 0, attach_ids)], 'body': tools.plaintext2html(body), 'body_html': body_html})
+ mail_message.write(cr, uid, mail_ids[0], {'attachment_ids': [(6, 0, attach_ids)], 'body': body_html})
url = self._make_url(cr, uid, res_id, model)
return (model, res_id, url, notify)