summaryrefslogtreecommitdiff
path: root/addons/thunderbird
diff options
context:
space:
mode:
authorRifakat Haradwala (Open ERP) <rha@tinyerp.com>2011-04-21 14:41:25 +0530
committerRifakat Haradwala (Open ERP) <rha@tinyerp.com>2011-04-21 14:41:25 +0530
commitb794d93e2a42eac8f3466c290b5ce7bdfc8a8547 (patch)
tree07b82d13b7c493329cae8150abb8467288a5a383 /addons/thunderbird
parentb511ca0034c5de98e7ffb6959ab9abdf0b3c80da (diff)
[FIX] thunderbird: changes in partner.py for history()
bzr revid: rha@tinyerp.com-20110421091125-nevt80ac5y1vn5jy
Diffstat (limited to 'addons/thunderbird')
-rw-r--r--addons/thunderbird/partner/partner.py33
1 files changed, 9 insertions, 24 deletions
diff --git a/addons/thunderbird/partner/partner.py b/addons/thunderbird/partner/partner.py
index 3d0f2937a1f..747625532b2 100644
--- a/addons/thunderbird/partner/partner.py
+++ b/addons/thunderbird/partner/partner.py
@@ -23,28 +23,6 @@ from osv import osv
import base64
import email
import tools
-import binascii
-class email_thread(osv.osv):
- _inherit = "email.thread"
- def history_message(self, cr, uid, model, res_id, message, context=None):
- #@param message: string of mail which is read from EML File
- attachment_pool = self.pool.get('ir.attachment')
- email_message_pool = self.pool.get('email.message')
- msg = email_message_pool.parse_message(message)
- attachments = msg.get('attachments', [])
- att_ids = []
- for attachment in attachments:
- data_attach = {
- 'name': attachment,
- 'datas': binascii.b2a_base64(str(attachments.get(attachment))),
- 'datas_fname': attachment,
- 'description': 'Mail attachment From Thunderbird msg_id: %s' %(msg.get('message_id', '')),
- 'res_model': model,
- 'res_id': res_id,
- }
- att_ids.append(attachment_pool.create(cr, uid, data_attach))
- return self.history(cr, uid, model, res_id, msg, att_ids)
-email_thread()
class thunderbird_partner(osv.osv_memory):
_name = "thunderbird.partner"
@@ -67,6 +45,7 @@ class thunderbird_partner(osv.osv_memory):
msg = dictcreate.get('message')
mail = msg
msg = self.pool.get('email.message').parse_message(msg)
+ subject = msg.get('Subject', False)
thread_pool = self.pool.get('email.thread')
message_id = msg.get('message-id', False)
msg_pool = self.pool.get('email.message')
@@ -75,7 +54,6 @@ class thunderbird_partner(osv.osv_memory):
res_ids = []
obj_list= ['crm.lead','project.issue','hr.applicant','res.partner']
for ref_id in ref_ids:
- msg_new = dictcreate.get('message')
ref = ref_id.split(',')
model = ref[0]
res_id = int(ref[1])
@@ -108,7 +86,14 @@ class thunderbird_partner(osv.osv_memory):
res['datas'] = base64.b64encode(mail)
res['res_id'] = res_id
obj_attch.create(cr, uid, res)
- thread_pool.history_message(cr, uid, model, res_id, msg_new)
+ threads = self.pool.get(model).browse(cr, uid, res_id)
+ thread_pool.history(cr, uid, [threads], subject,
+ email=msg.get('to', False),
+ details=msg.get('body', False),
+ email_from=msg.get('from', False),
+ message_id= msg.get('message-id', False),
+ attach= msg.get('attachments', {}),
+ email_date= msg.get('date', False))
res_ids.append(res_id)
return len(res_ids)