From 0c7876ac291b720b787f97834ded983b21c30025 Mon Sep 17 00:00:00 2001 From: "Yogesh (OpenERP)" Date: Mon, 7 Feb 2011 11:21:57 +0530 Subject: [IMP] replace mailgate.message to email.message in addons module. bzr revid: ysa@tinyerp.com-20110207055157-yr9co24w84kv0yvy --- addons/outlook/plugin/openerp-outlook-plugin/tiny_xmlrpc.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'addons/outlook/plugin/openerp-outlook-plugin/tiny_xmlrpc.py') diff --git a/addons/outlook/plugin/openerp-outlook-plugin/tiny_xmlrpc.py b/addons/outlook/plugin/openerp-outlook-plugin/tiny_xmlrpc.py index 761f99487a8..4d80948a585 100644 --- a/addons/outlook/plugin/openerp-outlook-plugin/tiny_xmlrpc.py +++ b/addons/outlook/plugin/openerp-outlook-plugin/tiny_xmlrpc.py @@ -177,14 +177,14 @@ class XMLRpcConn(object): model = rec[0] res_id = rec[1] #Check if mailgate installed - object_id = execute ( conn,'execute',self._dbname,int(self._uid),self._pwd,'ir.model','search',[('model','=','mailgate.message')]) + object_id = execute ( conn,'execute',self._dbname,int(self._uid),self._pwd,'ir.model','search',[('model','=','email.message')]) if not object_id: win32ui.MessageBox("Mailgate is not installed on your configured database '%s' !!\n\nPlease install it to archive the mail."%(self._dbname),"Mailgate not installed",win32con.MB_ICONERROR) return object_ids = execute ( conn,'execute',self._dbname,int(self._uid),self._pwd,'ir.model','search',[('model','=',model)]) object_name = execute( conn,'execute',self._dbname,int(self._uid),self._pwd,'ir.model','read',object_ids,['name'])[0]['name'] #Reading the Object ir.model Name - ext_ids = execute(conn,'execute',self._dbname,int(self._uid),self._pwd,'mailgate.message','search',[('message_id','=',message_id),('model','=',model),('res_id','=',res_id)]) + ext_ids = execute(conn,'execute',self._dbname,int(self._uid),self._pwd,'email.message','search',[('message_id','=',message_id),('model','=',model),('res_id','=',res_id)]) if ext_ids: name = execute(conn,'execute',self._dbname,int(self._uid),self._pwd,model,'read',res_id,['name'])['name'] ext_msg += """This mail is already archived to {0} '{1}'.\n""".format(object_name,name) @@ -457,19 +457,19 @@ class XMLRpcConn(object): import win32ui conn = xmlrpclib.ServerProxy(self._uri+ '/xmlrpc/object') res_vals = [] - mail_id = execute( conn, 'execute', self._dbname, int(self._uid), self._pwd, 'mailgate.message', 'search', [('message_id','=',message_id)]) + mail_id = execute( conn, 'execute', self._dbname, int(self._uid), self._pwd, 'email.message', 'search', [('message_id','=',message_id)]) ref_mail_id = None if not mail_id: - ref_mail_id = execute( conn, 'execute', self._dbname, int(self._uid), self._pwd, 'mailgate.message', 'search', [('references','=',message_id)]) + ref_mail_id = execute( conn, 'execute', self._dbname, int(self._uid), self._pwd, 'email.message', 'search', [('references','=',message_id)]) if ref_mail_id: win32ui.MessageBox(str(ref_mail_id),"ref_mail_id") - address = execute( conn, 'execute', self._dbname, int(self._uid), self._pwd, 'mailgate.message','read',ref_mail_id[0],['model','res_id']) + address = execute( conn, 'execute', self._dbname, int(self._uid), self._pwd, 'email.message','read',ref_mail_id[0],['model','res_id']) win32ui.MessageBox(str(address),"address") for key, vals in address.items(): res_vals.append([key,vals]) return res_vals return None - address = execute( conn, 'execute', self._dbname, int(self._uid), self._pwd, 'mailgate.message','read',mail_id[0],['model','res_id']) + address = execute( conn, 'execute', self._dbname, int(self._uid), self._pwd, 'email.message','read',mail_id[0],['model','res_id']) for key, vals in address.items(): res_vals.append([key,vals]) return res_vals -- cgit v1.2.3 From 455fb2d6b349df99449e1b8655349be8ce2869db Mon Sep 17 00:00:00 2001 From: "Rifakat Haradwala (Open ERP)" Date: Fri, 18 Mar 2011 19:14:19 +0530 Subject: [IMP] email: email cleanup bzr revid: rha@tinyerp.com-20110318134419-78qmipdipsryqgnz --- addons/outlook/plugin/openerp-outlook-plugin/tiny_xmlrpc.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'addons/outlook/plugin/openerp-outlook-plugin/tiny_xmlrpc.py') diff --git a/addons/outlook/plugin/openerp-outlook-plugin/tiny_xmlrpc.py b/addons/outlook/plugin/openerp-outlook-plugin/tiny_xmlrpc.py index 4892006516d..28244e84fe2 100644 --- a/addons/outlook/plugin/openerp-outlook-plugin/tiny_xmlrpc.py +++ b/addons/outlook/plugin/openerp-outlook-plugin/tiny_xmlrpc.py @@ -208,7 +208,7 @@ class XMLRpcConn(object): if attachments: result = self.MakeAttachment([rec], mail) attachment_ids = result.get(model, {}).get(res_id, []) - execute(conn,'execute',self._dbname,int(self._uid),self._pwd,'email.server.tools','history',model, res_id, msg, attachment_ids) + execute(conn,'execute',self._dbname,int(self._uid),self._pwd,'email.thread','history',model, res_id, msg, attachment_ids) new_msg += """- {0} : {1}\n""".format(object_name,str(rec[2])) flag = True @@ -298,7 +298,7 @@ class XMLRpcConn(object): endCut = message_id.find(">") message_id = message_id[startCut:endCut+1] email.replace_header('Message-Id',message_id) - id = execute(conn,'execute',self._dbname,int(self._uid),self._pwd,'email.server.tools','process_email',section, str(email)) + id = execute(conn,'execute',self._dbname,int(self._uid),self._pwd,'email.thread','process_email',section, str(email)) if id > 0: flag = True return flag -- cgit v1.2.3 From 2fa1c59ddf22564384ce9abe0809aa1f4cb6f072 Mon Sep 17 00:00:00 2001 From: "Rifakat Haradwala (Open ERP)" Date: Wed, 27 Apr 2011 19:17:11 +0530 Subject: [IMP] outlook,mail: improvements for outlook plugin bzr revid: rha@tinyerp.com-20110427134711-uqfm7m4s4lwj1tgi --- .../plugin/openerp-outlook-plugin/tiny_xmlrpc.py | 74 +++++++++++----------- 1 file changed, 36 insertions(+), 38 deletions(-) (limited to 'addons/outlook/plugin/openerp-outlook-plugin/tiny_xmlrpc.py') diff --git a/addons/outlook/plugin/openerp-outlook-plugin/tiny_xmlrpc.py b/addons/outlook/plugin/openerp-outlook-plugin/tiny_xmlrpc.py index 28244e84fe2..90aa90fd09e 100644 --- a/addons/outlook/plugin/openerp-outlook-plugin/tiny_xmlrpc.py +++ b/addons/outlook/plugin/openerp-outlook-plugin/tiny_xmlrpc.py @@ -20,6 +20,8 @@ ############################################################################## import xmlrpclib +import binascii +import base64 import sys import socket import os @@ -146,6 +148,7 @@ class XMLRpcConn(object): flag = False new_msg = ext_msg ="" message_id = referances = None + context = {} try: session = win32com.client.Dispatch("MAPI.session") session.Logon('Outlook') @@ -177,10 +180,10 @@ class XMLRpcConn(object): for rec in recs: #[('res.partner', 3, 'Agrolait')] model = rec[0] res_id = rec[1] - #Check if mailgate installed + #Check if mail installed object_id = execute ( conn,'execute',self._dbname,int(self._uid),self._pwd,'ir.model','search',[('model','=','email.message')]) if not object_id: - win32ui.MessageBox("Mailgate is not installed on your configured database '%s' !!\n\nPlease install it to archive the mail."%(self._dbname),"Mailgate not installed",win32con.MB_ICONERROR) + win32ui.MessageBox("Mail is not installed on your configured database '%s' !!\n\nPlease install it to archive the mail."%(self._dbname),"Mail not installed",win32con.MB_ICONERROR) return object_ids = execute ( conn,'execute',self._dbname,int(self._uid),self._pwd,'ir.model','search',[('model','=',model)]) object_name = execute( conn,'execute',self._dbname,int(self._uid),self._pwd,'ir.model','read',object_ids,['name'])[0]['name'] @@ -201,14 +204,19 @@ class XMLRpcConn(object): 'message-id':message_id, 'references':ustr(referances), } - obj_list= ['crm.lead','project.issue','hr.applicant','res.partner'] - if rec[0] not in obj_list: - self.CreateEmailAttachment(rec,mail) result = {} + context['thread_model'] = model if attachments: result = self.MakeAttachment([rec], mail) - attachment_ids = result.get(model, {}).get(res_id, []) - execute(conn,'execute',self._dbname,int(self._uid),self._pwd,'email.thread','history',model, res_id, msg, attachment_ids) + execute(conn,'execute',self._dbname,int(self._uid),self._pwd, \ + 'email.thread','history', [res_id], 'receive', \ + True, msg.get('subject',False),\ + msg.get('to'), msg.get('body', False),\ + msg.get('from'), msg.get('message-id'),\ + msg.get('references', False), result,\ + msg.get('cc'), False,\ + msg.get('date'), context) + new_msg += """- {0} : {1}\n""".format(object_name,str(rec[2])) flag = True @@ -310,39 +318,29 @@ class XMLRpcConn(object): return flag def MakeAttachment(self, recs, mail): - attachments = mail.Attachments - result = {} - conn = xmlrpclib.ServerProxy(self._uri+ '/xmlrpc/object') - att_folder_path = os.path.abspath(os.path.dirname("%temp%\\")) - if not os.path.exists(att_folder_path): + attachments = mail.Attachments + attachment = {} + conn = xmlrpclib.ServerProxy(self._uri+ '/xmlrpc/object') + att_folder_path = os.path.abspath(os.path.dirname("%temp%\\")) + if not os.path.exists(att_folder_path): os.makedirs(att_folder_path) for rec in recs: #[('res.partner', 3, 'Agrolait')] - obj = rec[0] - obj_id = rec[1] - res={} - res['res_model'] = obj - attachment_ids = [] - if obj not in result: - result[obj] = {} - for i in xrange(1, attachments.Count+1): - fn = ustr(attachments[i].FileName) - if len(fn) > 64: - l = 64 - len(fn) - f = fn.split('.') - fn = f[0][0:l] + '.' + f[-1] - att_path = os.path.join(att_folder_path,fn) - attachments[i].SaveAsFile(att_path) - f=open(att_path,"rb") - content = "".join(f.readlines()).encode('base64') - f.close() - res['name'] = ustr(attachments[i].DisplayName) - res['datas_fname'] = ustr(fn) - res['datas'] = content - res['res_id'] = obj_id - id = execute(conn,'execute',self._dbname,int(self._uid),self._pwd,'ir.attachment','create',res) - attachment_ids.append(id) - result[obj].update({obj_id: attachment_ids}) - return result + obj = rec[0] + obj_id = rec[1] + for i in xrange(1, attachments.Count+1): + fn = ustr(attachments[i].FileName) + if len(fn) > 64: + l = 64 - len(fn) + f = fn.split('.') + fn = f[0][0:l] + '.' + f[-1] + att_path = os.path.join(att_folder_path,fn) + attachments[i].SaveAsFile(att_path) + f=open(att_path,"rb") + content = "".join(f.readlines()).encode('base64') + f.close() + content = content.decode('base64') + attachment[fn] = content + return attachment def CreateContact(self, res=None): res=eval(str(res)) -- cgit v1.2.3 From 6b38a3a097023fce6ef017001296acb568040cbb Mon Sep 17 00:00:00 2001 From: "Rifakat Haradwala (Open ERP)" Date: Thu, 28 Apr 2011 15:45:28 +0530 Subject: [FIX] outlook: removed encodeing for the attachment content bzr revid: rha@tinyerp.com-20110428101528-pljylyati4kq3xls --- addons/outlook/plugin/openerp-outlook-plugin/tiny_xmlrpc.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'addons/outlook/plugin/openerp-outlook-plugin/tiny_xmlrpc.py') diff --git a/addons/outlook/plugin/openerp-outlook-plugin/tiny_xmlrpc.py b/addons/outlook/plugin/openerp-outlook-plugin/tiny_xmlrpc.py index 90aa90fd09e..4bafe893704 100644 --- a/addons/outlook/plugin/openerp-outlook-plugin/tiny_xmlrpc.py +++ b/addons/outlook/plugin/openerp-outlook-plugin/tiny_xmlrpc.py @@ -336,9 +336,8 @@ class XMLRpcConn(object): att_path = os.path.join(att_folder_path,fn) attachments[i].SaveAsFile(att_path) f=open(att_path,"rb") - content = "".join(f.readlines()).encode('base64') + content = "".join(f.readlines()) f.close() - content = content.decode('base64') attachment[fn] = content return attachment -- cgit v1.2.3 From 8f9f45ea948d1ffecb79601e860d522fc6686c2d Mon Sep 17 00:00:00 2001 From: Olivier Dony Date: Mon, 22 Aug 2011 19:16:59 +0200 Subject: [IMP] all: next pass of review/renaming for new mail API bzr revid: odo@openerp.com-20110822171659-zxho36a6n628i10q --- .../plugin/openerp-outlook-plugin/tiny_xmlrpc.py | 41 ++++++++++++++-------- 1 file changed, 26 insertions(+), 15 deletions(-) (limited to 'addons/outlook/plugin/openerp-outlook-plugin/tiny_xmlrpc.py') diff --git a/addons/outlook/plugin/openerp-outlook-plugin/tiny_xmlrpc.py b/addons/outlook/plugin/openerp-outlook-plugin/tiny_xmlrpc.py index 4bafe893704..cbd9482b1ae 100644 --- a/addons/outlook/plugin/openerp-outlook-plugin/tiny_xmlrpc.py +++ b/addons/outlook/plugin/openerp-outlook-plugin/tiny_xmlrpc.py @@ -181,14 +181,14 @@ class XMLRpcConn(object): model = rec[0] res_id = rec[1] #Check if mail installed - object_id = execute ( conn,'execute',self._dbname,int(self._uid),self._pwd,'ir.model','search',[('model','=','email.message')]) + object_id = execute ( conn,'execute',self._dbname,int(self._uid),self._pwd,'ir.model','search',[('model','=','mail.message')]) if not object_id: win32ui.MessageBox("Mail is not installed on your configured database '%s' !!\n\nPlease install it to archive the mail."%(self._dbname),"Mail not installed",win32con.MB_ICONERROR) return object_ids = execute ( conn,'execute',self._dbname,int(self._uid),self._pwd,'ir.model','search',[('model','=',model)]) object_name = execute( conn,'execute',self._dbname,int(self._uid),self._pwd,'ir.model','read',object_ids,['name'])[0]['name'] #Reading the Object ir.model Name - ext_ids = execute(conn,'execute',self._dbname,int(self._uid),self._pwd,'email.message','search',[('message_id','=',message_id),('model','=',model),('res_id','=',res_id)]) + ext_ids = execute(conn,'execute',self._dbname,int(self._uid),self._pwd,'mail.message','search',[('message_id','=',message_id),('model','=',model),('res_id','=',res_id)]) if ext_ids: name = execute(conn,'execute',self._dbname,int(self._uid),self._pwd,model,'read',res_id,['name'])['name'] ext_msg += """This mail is already archived to {0} '{1}'.\n""".format(object_name,name) @@ -208,14 +208,25 @@ class XMLRpcConn(object): context['thread_model'] = model if attachments: result = self.MakeAttachment([rec], mail) - execute(conn,'execute',self._dbname,int(self._uid),self._pwd, \ - 'email.thread','history', [res_id], 'receive', \ - True, msg.get('subject',False),\ - msg.get('to'), msg.get('body', False),\ - msg.get('from'), msg.get('message-id'),\ - msg.get('references', False), result,\ - msg.get('cc'), False,\ - msg.get('date'), context) + execute(conn, 'execute', self. _dbname, int(self._uid), self._pwd, + 'mail.thread','history',[res_id], + msg.get('subject', False), + msg.get('body', False), + msg.get('to', False), + msg.get('from', False), + msg.get('cc', False), + False, # BCC + False, #reply-to + msg.get('date', False), + msg.get('message-id'),\ + msg.get('references', False), + result, #attachments + #FIXME: properly handle plaintext/html body variants? + False, #body_html + False, #subtype + False, #headers + False, #original + context) new_msg += """- {0} : {1}\n""".format(object_name,str(rec[2])) flag = True @@ -306,7 +317,7 @@ class XMLRpcConn(object): endCut = message_id.find(">") message_id = message_id[startCut:endCut+1] email.replace_header('Message-Id',message_id) - id = execute(conn,'execute',self._dbname,int(self._uid),self._pwd,'email.thread','process_email',section, str(email)) + id = execute(conn,'execute',self._dbname,int(self._uid),self._pwd,'mail.thread','process_email',section, str(email)) if id > 0: flag = True return flag @@ -453,17 +464,17 @@ class XMLRpcConn(object): import win32ui conn = xmlrpclib.ServerProxy(self._uri+ '/xmlrpc/object') res_vals = [] - mail_id = execute( conn, 'execute', self._dbname, int(self._uid), self._pwd, 'email.message', 'search', [('message_id','=',message_id)]) + mail_id = execute( conn, 'execute', self._dbname, int(self._uid), self._pwd, 'mail.message', 'search', [('message_id','=',message_id)]) ref_mail_id = None if not mail_id: - ref_mail_id = execute( conn, 'execute', self._dbname, int(self._uid), self._pwd, 'email.message', 'search', [('references','=',message_id)]) + ref_mail_id = execute( conn, 'execute', self._dbname, int(self._uid), self._pwd, 'mail.message', 'search', [('references','like','%'+message_id+'%')]) if ref_mail_id: - address = execute( conn, 'execute', self._dbname, int(self._uid), self._pwd, 'email.message','read',ref_mail_id[0],['model','res_id']) + address = execute( conn, 'execute', self._dbname, int(self._uid), self._pwd, 'mail.message','read',ref_mail_id[0],['model','res_id']) for key, vals in address.items(): res_vals.append([key,vals]) return res_vals return None - address = execute( conn, 'execute', self._dbname, int(self._uid), self._pwd, 'email.message','read',mail_id[0],['model','res_id']) + address = execute( conn, 'execute', self._dbname, int(self._uid), self._pwd, 'mail.message','read',mail_id[0],['model','res_id']) for key, vals in address.items(): res_vals.append([key,vals]) return res_vals -- cgit v1.2.3 From b0bed63351956455a23cdc960292e104af53f67a Mon Sep 17 00:00:00 2001 From: Olivier Dony Date: Tue, 23 Aug 2011 19:58:09 +0200 Subject: [IMP] mail.thread: renaming methods to avoid collisions with objects that use the mixin bzr revid: odo@openerp.com-20110823175809-hw81fkptg90702vh --- addons/outlook/plugin/openerp-outlook-plugin/tiny_xmlrpc.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'addons/outlook/plugin/openerp-outlook-plugin/tiny_xmlrpc.py') diff --git a/addons/outlook/plugin/openerp-outlook-plugin/tiny_xmlrpc.py b/addons/outlook/plugin/openerp-outlook-plugin/tiny_xmlrpc.py index cbd9482b1ae..bcf20068718 100644 --- a/addons/outlook/plugin/openerp-outlook-plugin/tiny_xmlrpc.py +++ b/addons/outlook/plugin/openerp-outlook-plugin/tiny_xmlrpc.py @@ -317,7 +317,7 @@ class XMLRpcConn(object): endCut = message_id.find(">") message_id = message_id[startCut:endCut+1] email.replace_header('Message-Id',message_id) - id = execute(conn,'execute',self._dbname,int(self._uid),self._pwd,'mail.thread','process_email',section, str(email)) + id = execute(conn,'execute',self._dbname,int(self._uid),self._pwd,'mail.thread','message_process',section, str(email)) if id > 0: flag = True return flag -- cgit v1.2.3 From 2f543db06e952991577ca659f6b9b4dfc57cf828 Mon Sep 17 00:00:00 2001 From: Olivier Dony Date: Thu, 25 Aug 2011 14:27:57 +0200 Subject: [IMP] mail: cleanup/rename API + adapt dependencies (wip) bzr revid: odo@openerp.com-20110825122757-0mqr0gbol25t0n41 --- addons/outlook/plugin/openerp-outlook-plugin/tiny_xmlrpc.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'addons/outlook/plugin/openerp-outlook-plugin/tiny_xmlrpc.py') diff --git a/addons/outlook/plugin/openerp-outlook-plugin/tiny_xmlrpc.py b/addons/outlook/plugin/openerp-outlook-plugin/tiny_xmlrpc.py index bcf20068718..41346fe7cf9 100644 --- a/addons/outlook/plugin/openerp-outlook-plugin/tiny_xmlrpc.py +++ b/addons/outlook/plugin/openerp-outlook-plugin/tiny_xmlrpc.py @@ -209,7 +209,7 @@ class XMLRpcConn(object): if attachments: result = self.MakeAttachment([rec], mail) execute(conn, 'execute', self. _dbname, int(self._uid), self._pwd, - 'mail.thread','history',[res_id], + 'mail.thread','message_append',[res_id], msg.get('subject', False), msg.get('body', False), msg.get('to', False), -- cgit v1.2.3