[IMP] Thunderbird : Adding Text file of the mail while archiving mail to the Object for reference

bzr revid: jam@tinyerp.com-20101110105305-olq2el9azyo2ao2e
This commit is contained in:
jam-openerp 2010-11-10 16:23:05 +05:30
parent cee55d9071
commit 0c38b3c219
1 changed files with 26 additions and 0 deletions

View File

@ -159,6 +159,7 @@ class thunderbird_partner(osv.osv_memory):
msg_ids = []
res = {}
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(',')
@ -168,6 +169,31 @@ class thunderbird_partner(osv.osv_memory):
msg_ids = msg_pool.search(cr, uid, [('message_id','=',message_id),('res_id','=',res_id),('model','=',model)])
if msg_ids and len(msg_ids):
continue
if model not in obj_list:
res={}
obj_attch = self.pool.get('ir.attachment')
ls = ['*', '/', '\\', '<', '>', ':', '?', '"', '|', '\t', '\n',':','~']
sub = (email.Subject).replace(' ','')
if sub.strip() == '':
sub = 'NO SBUJECT'
fn = sub
for c in ls:
fn = fn.replace(c,'')
if len(fn) > 64:
l = 64 - len(fn)
f = fn.split('-')
fn = '-'.join(f[1:])
if len(fn) > 64:
l = 64 - len(fn)
f = fn.split('.')
fn = f[0][0:l] + '.' + f[-1]
fn = fn[:-4]+'.txt'
res['res_model'] = model
res['name'] = msg.get('subject','NO-SUBJECT')
res['datas_fname'] = fn
res['datas'] = base64.b64encode(msg.get('body'))
res['res_id'] = res_id
obj_attch.create(cr, uid, res)
server_tools_pool.history_message(cr, uid, model, res_id, msg_new)
res_ids.append(res_id)
return len(res_ids)