diff options
| author | Denis Ledoux <dle@openerp.com> | 2014-01-24 13:10:27 +0100 |
|---|---|---|
| committer | Denis Ledoux <dle@openerp.com> | 2014-01-24 13:10:27 +0100 |
| commit | 1fb1a6f2af794256b5e27c7a875169d02fc6381c (patch) | |
| tree | 6d1c5a3958f5d0eb9e2b588fd1a865e79fbafa07 /addons/plugin/plugin_handler.py | |
| parent | 9f3ab4599c7267b82b1d5255f31ef67b56594a68 (diff) | |
| parent | 83677ed6e6d662ef715e14f99dda7f696dc23f93 (diff) | |
[MERGE] Forward-port of latest 7.0 bugfixes, up to rev. 9789 revid:dle@openerp.com-20140124120102-we2yxio553ws2yz4
bzr revid: dle@openerp.com-20140120174449-tui0a24zgn9bien2
bzr revid: dle@openerp.com-20140121125538-ke7i6kaz486hwgl8
bzr revid: dle@openerp.com-20140122134115-0ogjemlqe327xoac
bzr revid: dle@openerp.com-20140123103655-mf2zslfbgue97ed2
bzr revid: dle@openerp.com-20140124121027-uk9zy4dx9tqlsblr
Diffstat (limited to 'addons/plugin/plugin_handler.py')
| -rw-r--r-- | addons/plugin/plugin_handler.py | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/addons/plugin/plugin_handler.py b/addons/plugin/plugin_handler.py index fc6c874fab5..bdc0a50810b 100644 --- a/addons/plugin/plugin_handler.py +++ b/addons/plugin/plugin_handler.py @@ -93,8 +93,9 @@ class plugin_handler(osv.osv_memory): """ mail_message = self.pool.get('mail.message') model_obj = self.pool[model] - msg = self.pool.get('mail.thread').message_parse(cr, uid, email) - message_id = msg.get('message-id') + 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: mail_record = mail_message.browse(cr, uid, mail_ids)[0] @@ -107,12 +108,22 @@ 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') + if email_from: + author_id = False + else: + authors = mail_thread_obj.message_find_partner_from_emails(cr, uid, [res_id], [email_from]) + author_id = authors and authors[0].get('partner_id') or False + model_obj.message_post(cr, uid, [res_id], body=msg.get('body'), subject=msg.get('subject'), type='comment' if model == 'res.partner' else 'email', parent_id=msg.get('parent_id'), - attachments=msg.get('attachments')) + attachments=msg.get('attachments'), + message_id=message_id, + 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) @@ -151,7 +162,7 @@ class plugin_handler(osv.osv_memory): ir_attachment_obj = self.pool.get('ir.attachment') attach_ids = [] msg = self.pool.get('mail.thread').message_parse(cr, uid, headers) - message_id = msg.get('message-id') + message_id = msg.get('message_id') push_mail = self.push_message(cr, uid, model, headers, res_id) res_id = push_mail[1] model = push_mail[0] @@ -165,6 +176,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': 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) |
