From bc3c1f7a22dbca3c418f700cf48883617e53933e Mon Sep 17 00:00:00 2001 From: jam-openerp Date: Fri, 12 Nov 2010 17:16:44 +0530 Subject: [FIX] Cleaning of the File bzr revid: jam@tinyerp.com-20101112114644-u2rlqco4mebcl2yn --- .../plugin/openerp-outlook-plugin/tiny_xmlrpc.py | 748 ++++++++++----------- 1 file changed, 374 insertions(+), 374 deletions(-) (limited to 'addons/outlook/plugin') diff --git a/addons/outlook/plugin/openerp-outlook-plugin/tiny_xmlrpc.py b/addons/outlook/plugin/openerp-outlook-plugin/tiny_xmlrpc.py index c4efe23cddc..d91edd704d0 100644 --- a/addons/outlook/plugin/openerp-outlook-plugin/tiny_xmlrpc.py +++ b/addons/outlook/plugin/openerp-outlook-plugin/tiny_xmlrpc.py @@ -27,11 +27,13 @@ import time from manager import ustr from win32com.mapi import mapitags import pythoncom -import win32com +import win32com import win32ui + waittime = 10 wait_count = 0 wait_limit = 12 + def execute(connector, method, *args): global wait_count res = False @@ -68,447 +70,444 @@ class XMLRpcConn(object): self._server=server self._port=port self._uri=uri - self._obj_list=[] - self._dbname='' - self._uname='admin' - self._pwd='a' - self._login=False - self._running=False - self._uid=False - self._iscrm=True - self.partner_id_list=None - self.protocol=None + self._obj_list=[] + self._dbname='' + self._uname='admin' + self._pwd='a' + self._login=False + self._running=False + self._uid=False + self._iscrm=True + self.partner_id_list=None + self.protocol=None def getitem(self, attrib): - v=self.__getattribute__(attrib) - return str(v) + v=self.__getattribute__(attrib) + return str(v) def setitem(self, attrib, value): - return self.__setattr__(attrib, value) + return self.__setattr__(attrib, value) def GetDBList(self): - conn = xmlrpclib.ServerProxy(self._uri + '/xmlrpc/db') - try: - db_list = execute(conn, 'list') - if db_list == False: - self._running=False - return [] - else: - self._running=True - except: - db_list=-1 - self._running=True - return db_list + conn = xmlrpclib.ServerProxy(self._uri + '/xmlrpc/db') + try: + db_list = execute(conn, 'list') + if db_list == False: + self._running=False + return [] + else: + self._running=True + except: + db_list=-1 + self._running=True + return db_list def login(self,dbname, user, pwd): - self._dbname = dbname - self._uname = user - self._pwd = pwd - conn = xmlrpclib.ServerProxy(str(self._uri) + '/xmlrpc/common') - uid = execute(conn,'login',dbname, ustr(user), ustr(pwd)) - return uid + self._dbname = dbname + self._uname = user + self._pwd = pwd + conn = xmlrpclib.ServerProxy(str(self._uri) + '/xmlrpc/common') + uid = execute(conn,'login',dbname, ustr(user), ustr(pwd)) + return uid def GetAllObjects(self): - conn = xmlrpclib.ServerProxy(self._uri+ '/xmlrpc/object') - ids = execute(conn,'execute',self._dbname,int(self._uid),self._pwd,'ir.model','search',[]) - objects = execute(conn,'execute',self._dbname,int(self._uid),self._pwd,'ir.model','read',ids,['model']) - obj_list = [item['model'] for item in objects] - return obj_list + conn = xmlrpclib.ServerProxy(self._uri+ '/xmlrpc/object') + ids = execute(conn,'execute',self._dbname,int(self._uid),self._pwd,'ir.model','search',[]) + objects = execute(conn,'execute',self._dbname,int(self._uid),self._pwd,'ir.model','read',ids,['model']) + obj_list = [item['model'] for item in objects] + return obj_list def GetObjList(self): - self._obj_list=list(self._obj_list) - self._obj_list.sort(reverse=True) - return self._obj_list + self._obj_list=list(self._obj_list) + self._obj_list.sort(reverse=True) + return self._obj_list def InsertObj(self, obj_title,obj_name,image_path): - self._obj_list=list(self._obj_list) - self._obj_list.append((obj_title,obj_name,ustr(image_path))) - self._obj_list.sort(reverse=True) + self._obj_list=list(self._obj_list) + self._obj_list.append((obj_title,obj_name,ustr(image_path))) + self._obj_list.sort(reverse=True) def DeleteObject(self,sel_text): - self._obj_list=list(self._obj_list) - for obj in self._obj_list: - if obj[0] == sel_text: - self._obj_list.remove(obj) - break + self._obj_list=list(self._obj_list) + for obj in self._obj_list: + if obj[0] == sel_text: + self._obj_list.remove(obj) + break def ArchiveToOpenERP(self, recs, mail): - import win32con - conn = xmlrpclib.ServerProxy(self._uri + '/xmlrpc/object') - flag = False - new_msg = ext_msg ="" - message_id = referances = None - try: - session = win32com.client.Dispatch("MAPI.session") - session.Logon('Outlook') - objMessage = session.GetMessage(mail.EntryID, mail.Parent.StoreID) - objFields = objMessage.Fields - strheader = objFields.Item(mapitags.PR_TRANSPORT_MESSAGE_HEADERS) - strheader = ustr(strheader).encode('iso-8859-1') - headers = {} - strheader = strheader.replace("\n ", " ").splitlines() - for line in strheader: - split_here = line.find(":") - headers[line[:split_here]] = line[split_here:] - temp1 = headers.get('Message-ID') - temp2 = headers.get('Message-Id') - referances = headers.get('References') - if temp1 == None: message_id = temp2 - if temp2 == None: message_id = temp1 - startCut = message_id.find("<") - endCut = message_id.find(">") - message_id = message_id[startCut:endCut+1] - if not referances == None: - startCut = referances.find("<") - endCut = referances.find(">") - referances = referances[startCut:endCut+1] - except Exception,e: - win32ui.MessageBox(str(e),"Archive To OpenERP") - return - attachments=mail.Attachments - for rec in recs: #[('res.partner', 3, 'Agrolait')] + import win32con + conn = xmlrpclib.ServerProxy(self._uri + '/xmlrpc/object') + flag = False + new_msg = ext_msg ="" + message_id = referances = None + try: + session = win32com.client.Dispatch("MAPI.session") + session.Logon('Outlook') + objMessage = session.GetMessage(mail.EntryID, mail.Parent.StoreID) + objFields = objMessage.Fields + strheader = objFields.Item(mapitags.PR_TRANSPORT_MESSAGE_HEADERS) + strheader = ustr(strheader).encode('iso-8859-1') + headers = {} + strheader = strheader.replace("\n ", " ").splitlines() + for line in strheader: + split_here = line.find(":") + headers[line[:split_here]] = line[split_here:] + temp1 = headers.get('Message-ID') + temp2 = headers.get('Message-Id') + referances = headers.get('References') + if temp1 == None: message_id = temp2 + if temp2 == None: message_id = temp1 + startCut = message_id.find("<") + endCut = message_id.find(">") + message_id = message_id[startCut:endCut+1] + if not referances == None: + startCut = referances.find("<") + endCut = referances.find(">") + referances = referances[startCut:endCut+1] + except Exception,e: + win32ui.MessageBox(str(e),"Archive To OpenERP") + return + attachments=mail.Attachments + for rec in recs: #[('res.partner', 3, 'Agrolait')] 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')]) 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 + 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)]) 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) - flag = True - continue + 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) + flag = True + continue msg = { - 'subject':mail.Subject, - 'date':str(mail.ReceivedTime), - 'body':mail.Body, - 'cc':mail.CC, - 'from':mail.SenderEmailAddress, - 'to':mail.To, - 'message-id':message_id, - 'references':ustr(referances), + 'subject':mail.Subject, + 'date':str(mail.ReceivedTime), + 'body':mail.Body, + 'cc':mail.CC, + 'from':mail.SenderEmailAddress, + 'to':mail.To, + 'message-id':message_id, + 'references':ustr(referances), } obj_list= ['crm.lead','project.issue','hr.applicant','res.partner'] if rec[0] not in obj_list: ids = self.CreateEmailAttachment(rec,mail) result = {} if attachments: - result = self.MakeAttachment([rec], mail) + result = self.MakeAttachment([rec], mail) attachment_ids = result.get(model, {}).get(res_id, []) ids = execute(conn,'execute',self._dbname,int(self._uid),self._pwd,'email.server.tools','history',model, res_id, msg, attachment_ids) new_msg += """- {0} : {1}\n""".format(object_name,str(rec[2])) flag = True - - if flag: - t = """Mail archived Successfully with attachments.\n"""+ext_msg - t += "\n"+new_msg - win32ui.MessageBox(t,"Archived to OpenERP",win32con.MB_ICONINFORMATION) - return flag + if flag: + t = """Mail archived Successfully with attachments.\n"""+ext_msg + t += "\n"+new_msg + win32ui.MessageBox(t,"Archived to OpenERP",win32con.MB_ICONINFORMATION) + return flag def IsCRMInstalled(self): - conn = xmlrpclib.ServerProxy(self._uri+ '/xmlrpc/object') - id = execute(conn,'execute',self._dbname,int(self._uid),self._pwd,'ir.model','search',[('model','=','crm.lead')]) - return id + conn = xmlrpclib.ServerProxy(self._uri+ '/xmlrpc/object') + id = execute(conn,'execute',self._dbname,int(self._uid),self._pwd,'ir.model','search',[('model','=','crm.lead')]) + return id def GetCSList(self): - conn = xmlrpclib.ServerProxy(self._uri+ '/xmlrpc/object') - ids = execute(conn,'execute',self._dbname,int(int(self._uid)),self._pwd,'crm.case.section','search',[]) - objects = execute(conn,'execute',self._dbname,int(self._uid),self._pwd,'crm.case.section','read',ids,['name']) - obj_list = [ustr(item['name']).encode('iso-8859-1') for item in objects] - return obj_list + conn = xmlrpclib.ServerProxy(self._uri+ '/xmlrpc/object') + ids = execute(conn,'execute',self._dbname,int(int(self._uid)),self._pwd,'crm.case.section','search',[]) + objects = execute(conn,'execute',self._dbname,int(self._uid),self._pwd,'crm.case.section','read',ids,['name']) + obj_list = [ustr(item['name']).encode('iso-8859-1') for item in objects] + return obj_list def GetPartners(self, search_partner=''): - conn = xmlrpclib.ServerProxy(self._uri+ '/xmlrpc/object') - ids=[] - obj_list=[] - domain = [] - if not search_partner.strip() == '': - domain.append(('name','ilike',ustr(search_partner))) - ids = execute(conn,'execute',self._dbname,int(self._uid),self._pwd,'res.partner','search',domain) - if ids: - ids.sort() - obj_list.append((-999, ustr(''))) - for id in ids: - object = execute(conn,'execute',self._dbname,int(self._uid),self._pwd,'res.partner','read',[id],['id','name'])[0] - obj_list.append((object['id'], ustr(object['name']))) - obj_list.sort(lambda x, y: cmp(x[1],y[1])) - return obj_list + conn = xmlrpclib.ServerProxy(self._uri+ '/xmlrpc/object') + ids=[] + obj_list=[] + domain = [] + if not search_partner.strip() == '': + domain.append(('name','ilike',ustr(search_partner))) + ids = execute(conn,'execute',self._dbname,int(self._uid),self._pwd,'res.partner','search',domain) + if ids: + ids.sort() + obj_list.append((-999, ustr(''))) + for id in ids: + object = execute(conn,'execute',self._dbname,int(self._uid),self._pwd,'res.partner','read',[id],['id','name'])[0] + obj_list.append((object['id'], ustr(object['name']))) + obj_list.sort(lambda x, y: cmp(x[1],y[1])) + return obj_list def GetObjectItems(self, search_list=[], search_text=''): - res = [] - conn = xmlrpclib.ServerProxy(self._uri+ '/xmlrpc/object') - for obj in search_list: - object_ids = execute ( conn,'execute',self._dbname,int(self._uid),self._pwd,'ir.model','search',[('model','=',obj)]) - object_name = execute( conn,'execute',self._dbname,int(self._uid),self._pwd,'ir.model','read',object_ids,['name'])[0]['name'] - if obj == "res.partner.address": - ids = execute(conn,'execute',self._dbname,int(self._uid),self._pwd,obj,'search',['|',('name','ilike',ustr(search_text)),('email','ilike',ustr(search_text))]) - recs = execute(conn,'execute',self._dbname,int(self._uid),self._pwd,obj,'read',ids,['id','name','street','city']) - for rec in recs: - name = ustr(rec['name']) - if rec['street']: - name += ', ' + ustr(rec['street']) - if rec['city']: - name += ', ' + ustr(rec['city']) - res.append((obj,rec['id'],name,object_name)) - else: - ids = execute(conn,'execute',self._dbname,int(self._uid),self._pwd,obj,'search',[('name','ilike',ustr(search_text))]) - recs = execute(conn,'execute',self._dbname,int(self._uid),self._pwd,obj,'read',ids,['id','name']) - for rec in recs: - name = ustr(rec['name']) - res.append((obj,rec['id'],name,object_name)) - return res + res = [] + conn = xmlrpclib.ServerProxy(self._uri+ '/xmlrpc/object') + for obj in search_list: + object_ids = execute ( conn,'execute',self._dbname,int(self._uid),self._pwd,'ir.model','search',[('model','=',obj)]) + object_name = execute( conn,'execute',self._dbname,int(self._uid),self._pwd,'ir.model','read',object_ids,['name'])[0]['name'] + if obj == "res.partner.address": + ids = execute(conn,'execute',self._dbname,int(self._uid),self._pwd,obj,'search',['|',('name','ilike',ustr(search_text)),('email','ilike',ustr(search_text))]) + recs = execute(conn,'execute',self._dbname,int(self._uid),self._pwd,obj,'read',ids,['id','name','street','city']) + for rec in recs: + name = ustr(rec['name']) + if rec['street']: + name += ', ' + ustr(rec['street']) + if rec['city']: + name += ', ' + ustr(rec['city']) + res.append((obj,rec['id'],name,object_name)) + else: + ids = execute(conn,'execute',self._dbname,int(self._uid),self._pwd,obj,'search',[('name','ilike',ustr(search_text))]) + recs = execute(conn,'execute',self._dbname,int(self._uid),self._pwd,obj,'read',ids,['id','name']) + for rec in recs: + name = ustr(rec['name']) + res.append((obj,rec['id'],name,object_name)) + return res_id def CreateCase(self, section, mail, partner_ids, with_attachments=True): - import eml - flag = False - id = -1 - try: - conn = xmlrpclib.ServerProxy(self._uri+ '/xmlrpc/object') - email=eml.generateEML(mail) - message_id = None - session = win32com.client.Dispatch("MAPI.session") - session.Logon('Outlook') - objMessage = session.GetMessage(mail.EntryID, mail.Parent.StoreID) - objFields = objMessage.Fields - strheader = objFields.Item(mapitags.PR_TRANSPORT_MESSAGE_HEADERS) - strheader = ustr(strheader).encode('iso-8859-1') - headers = {} - strheader = strheader.replace("\n ", " ").splitlines() - for line in strheader: - split_here = line.find(":") - headers[line[:split_here]] = line[split_here:] - temp1 = headers.get('Message-ID') - temp2 = headers.get('Message-Id') - if temp1 == None: message_id = temp2 - if temp2 == None: message_id = temp1 - startCut = message_id.find("<") - 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)) - if id > 0: - flag = True - return flag - else: - flag = False - return flag - except Exception,e: - win32ui.MessageBox("Create Case\n"+str(e),"Mail Reading Error") - return flag + import eml + flag = False + id = -1 + try: + conn = xmlrpclib.ServerProxy(self._uri+ '/xmlrpc/object') + email=eml.generateEML(mail) + message_id = None + session = win32com.client.Dispatch("MAPI.session") + session.Logon('Outlook') + objMessage = session.GetMessage(mail.EntryID, mail.Parent.StoreID) + objFields = objMessage.Fields + strheader = objFields.Item(mapitags.PR_TRANSPORT_MESSAGE_HEADERS) + strheader = ustr(strheader).encode('iso-8859-1') + headers = {} + strheader = strheader.replace("\n ", " ").splitlines() + for line in strheader: + split_here = line.find(":") + headers[line[:split_here]] = line[split_here:] + temp1 = headers.get('Message-ID') + temp2 = headers.get('Message-Id') + if temp1 == None: message_id = temp2 + if temp2 == None: message_id = temp1 + startCut = message_id.find("<") + 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)) + if id > 0: + flag = True + return flag + else: + flag = False + return flag + except Exception,e: + win32ui.MessageBox("Create Case\n"+str(e),"Mail Reading Error") + 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): - 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 + 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): + 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 def CreateContact(self, res=None): - res=eval(str(res)) - partner = res['partner_id'] - state = res['state_id'] - country = res['country_id'] - conn = xmlrpclib.ServerProxy(self._uri+ '/xmlrpc/object') - if not partner.strip() == '': - partner_id = execute( conn, 'execute', self._dbname, int(self._uid), self._pwd, 'res.partner', 'search', [('name','=',ustr(partner))]) - res.update({'partner_id' : partner_id[0]}) - else: - res.pop('partner_id') - if not state == "": - country_id = execute( conn, 'execute', self._dbname, int(self._uid), self._pwd, 'res.country', 'search', [('name','=',ustr(country))]) - res.update({'country_id' : country_id[0]}) - else: - res.pop('country_id') - if not country == "": - state_id = execute( conn, 'execute', self._dbname, int(self._uid), self._pwd, 'res.country.state', 'search', [('name','=',ustr(state))]) - res.update({'state_id' : state_id[0]}) - else: - res.pop('state_id') - id = execute(conn,'execute',self._dbname,int(self._uid),self._pwd,'res.partner.address','create',res) - return id + res=eval(str(res)) + partner = res['partner_id'] + state = res['state_id'] + country = res['country_id'] + conn = xmlrpclib.ServerProxy(self._uri+ '/xmlrpc/object') + if not partner.strip() == '': + partner_id = execute( conn, 'execute', self._dbname, int(self._uid), self._pwd, 'res.partner', 'search', [('name','=',ustr(partner))]) + res.update({'partner_id' : partner_id[0]}) + else: + res.pop('partner_id') + if not state == "": + country_id = execute( conn, 'execute', self._dbname, int(self._uid), self._pwd, 'res.country', 'search', [('name','=',ustr(country))]) + res.update({'country_id' : country_id[0]}) + else: + res.pop('country_id') + if not country == "": + state_id = execute( conn, 'execute', self._dbname, int(self._uid), self._pwd, 'res.country.state', 'search', [('name','=',ustr(state))]) + res.update({'state_id' : state_id[0]}) + else: + res.pop('state_id') + id = execute(conn,'execute',self._dbname,int(self._uid),self._pwd,'res.partner.address','create',res) + return id def CreatePartner(self, res): - res=eval(str(res)) - conn = xmlrpclib.ServerProxy(self._uri+ '/xmlrpc/object') - ids = execute(conn,'execute',self._dbname,int(self._uid),self._pwd,'res.partner','search',[('name','=',res['name'])]) - if ids: - return False - id = execute(conn,'execute',self._dbname,int(self._uid),self._pwd,'res.partner','create',res) - return id + res=eval(str(res)) + conn = xmlrpclib.ServerProxy(self._uri+ '/xmlrpc/object') + ids = execute(conn,'execute',self._dbname,int(self._uid),self._pwd,'res.partner','search',[('name','=',res['name'])]) + if ids: + return False + id = execute(conn,'execute',self._dbname,int(self._uid),self._pwd,'res.partner','create',res) + return id def SearchPartnerDetail(self, search_email_id): - res_vals = [] - conn = xmlrpclib.ServerProxy(self._uri+ '/xmlrpc/object') - address_id = execute(conn, 'execute', self._dbname, int(self._uid), self._pwd, 'res.partner.address', 'search', [('email','ilike',ustr(search_email_id))]) - if not address_id : - return - address = execute(conn, 'execute', self._dbname, int(self._uid), self._pwd, 'res.partner.address','read',address_id[0],['id','partner_id','name','street','street2','city','state_id','country_id','phone','mobile','email','fax','zip']) - for key, vals in address.items(): - res_vals.append([key,vals]) - return res_vals + res_vals = [] + conn = xmlrpclib.ServerProxy(self._uri+ '/xmlrpc/object') + address_id = execute(conn, 'execute', self._dbname, int(self._uid), self._pwd, 'res.partner.address', 'search', [('email','ilike',ustr(search_email_id))]) + if not address_id : + return + address = execute(conn, 'execute', self._dbname, int(self._uid), self._pwd, 'res.partner.address','read',address_id[0],['id','partner_id','name','street','street2','city','state_id','country_id','phone','mobile','email','fax','zip']) + for key, vals in address.items(): + res_vals.append([key,vals]) + return res_vals def WritePartnerValues(self, new_vals): - flag = -1 - new_dict = dict(new_vals) - email=new_dict['email'] - partner = new_dict['partner'] - country_val = new_dict['country'] - state_val = new_dict['state'] - conn = xmlrpclib.ServerProxy(self._uri+ '/xmlrpc/object') - partner_id = execute( conn, 'execute', self._dbname, int(self._uid), self._pwd, 'res.partner', 'search', [('name','=',ustr(partner))]) - country_id = execute( conn, 'execute', self._dbname, int(self._uid), self._pwd, 'res.country', 'search', [('name','=',ustr(country_val))]) - state_id = execute( conn, 'execute', self._dbname, int(self._uid), self._pwd, 'res.country.state', 'search', [('name','=',ustr(state_val))]) - address_id = execute( conn, 'execute', self._dbname, int(self._uid), self._pwd, 'res.partner.address', 'search', [('email','=',ustr(email))]) - if not partner_id or not address_id or not country_id or not state_id: - return flag - address = execute( conn, 'execute', self._dbname, int(self._uid), self._pwd, 'res.partner.address','read',address_id[0],['id','partner_id','state_id','country_id']) - vals_res_address={ - 'partner_id' : partner_id[0], - 'name' : new_dict['name'], - 'street':new_dict['street'], - 'street2' : new_dict['street2'], - 'city' : new_dict['city'], - 'phone' : new_dict['phone'], - 'mobile' : new_dict['mobile'], - 'fax' : new_dict['fax'], - 'zip' : new_dict['zip'], - 'country_id' : country_id[0], - 'state_id' : state_id[0] - } - temp = execute( conn, 'execute', self._dbname, int(self._uid), self._pwd, 'res.partner.address', 'write', address_id, vals_res_address) - if temp: - flag=1 - else: - flag=0 - return flag + flag = -1 + new_dict = dict(new_vals) + email=new_dict['email'] + partner = new_dict['partner'] + country_val = new_dict['country'] + state_val = new_dict['state'] + conn = xmlrpclib.ServerProxy(self._uri+ '/xmlrpc/object') + partner_id = execute( conn, 'execute', self._dbname, int(self._uid), self._pwd, 'res.partner', 'search', [('name','=',ustr(partner))]) + country_id = execute( conn, 'execute', self._dbname, int(self._uid), self._pwd, 'res.country', 'search', [('name','=',ustr(country_val))]) + state_id = execute( conn, 'execute', self._dbname, int(self._uid), self._pwd, 'res.country.state', 'search', [('name','=',ustr(state_val))]) + address_id = execute( conn, 'execute', self._dbname, int(self._uid), self._pwd, 'res.partner.address', 'search', [('email','=',ustr(email))]) + if not partner_id or not address_id or not country_id or not state_id: + return flag + address = execute( conn, 'execute', self._dbname, int(self._uid), self._pwd, 'res.partner.address','read',address_id[0],['id','partner_id','state_id','country_id']) + vals_res_address={ + 'partner_id' : partner_id[0], + 'name' : new_dict['name'], + 'street':new_dict['street'], + 'street2' : new_dict['street2'], + 'city' : new_dict['city'], + 'phone' : new_dict['phone'], + 'mobile' : new_dict['mobile'], + 'fax' : new_dict['fax'], + 'zip' : new_dict['zip'], + 'country_id' : country_id[0], + 'state_id' : state_id[0] + } + temp = execute( conn, 'execute', self._dbname, int(self._uid), self._pwd, 'res.partner.address', 'write', address_id, vals_res_address) + if temp: + flag=1 + else: + flag=0 + return flag def GetAllState(self): - state_list = [] - state_ids = [] - conn = xmlrpclib.ServerProxy(self._uri+ '/xmlrpc/object') - state_ids = execute( conn, 'execute', self._dbname, int(self._uid), self._pwd, 'res.country.state', 'search', []) - for state_id in state_ids: - obj = execute( conn, 'execute', self._dbname, int(self._uid), self._pwd, 'res.country.state', 'read', [state_id],['id','name'])[0] - state_list.append((obj['id'], ustr(obj['name']))) - return state_list + state_list = [] + state_ids = [] + conn = xmlrpclib.ServerProxy(self._uri+ '/xmlrpc/object') + state_ids = execute( conn, 'execute', self._dbname, int(self._uid), self._pwd, 'res.country.state', 'search', []) + for state_id in state_ids: + obj = execute( conn, 'execute', self._dbname, int(self._uid), self._pwd, 'res.country.state', 'read', [state_id],['id','name'])[0] + state_list.append((obj['id'], ustr(obj['name']))) + return state_list def GetAllCountry(self): - country_list = [] - country_ids = [] - conn = xmlrpclib.ServerProxy(self._uri+ '/xmlrpc/object') - country_ids = execute( conn, 'execute', self._dbname, int(self._uid), self._pwd, 'res.country', 'search', []) - for country_id in country_ids: - obj = execute( conn, 'execute', self._dbname, int(self._uid), self._pwd, 'res.country','read', [country_id], ['id','name'])[0] - country_list.append((obj['id'], ustr(obj['name']))) - return country_list + country_list = [] + country_ids = [] + conn = xmlrpclib.ServerProxy(self._uri+ '/xmlrpc/object') + country_ids = execute( conn, 'execute', self._dbname, int(self._uid), self._pwd, 'res.country', 'search', []) + for country_id in country_ids: + obj = execute( conn, 'execute', self._dbname, int(self._uid), self._pwd, 'res.country','read', [country_id], ['id','name'])[0] + country_list.append((obj['id'], ustr(obj['name']))) + return country_list def SearchPartner(self, mail_id = ""): - conn = xmlrpclib.ServerProxy(self._uri+ '/xmlrpc/object') - address = execute( conn, 'execute', self._dbname, int(self._uid), self._pwd, 'res.partner.address', 'search', [('email','=',ustr(mail_id))]) - if not address: - return None - else: - add_rec = execute( conn, 'execute', self._dbname, int(self._uid), self._pwd, 'res.partner.address', 'read', address[0]) - partner = add_rec.get('partner_id',False) - if partner: - return partner[0] + conn = xmlrpclib.ServerProxy(self._uri+ '/xmlrpc/object') + address = execute( conn, 'execute', self._dbname, int(self._uid), self._pwd, 'res.partner.address', 'search', [('email','=',ustr(mail_id))]) + if not address: + return None + else: + add_rec = execute( conn, 'execute', self._dbname, int(self._uid), self._pwd, 'res.partner.address', 'read', address[0]) + partner = add_rec.get('partner_id',False) + if partner: + return partner[0] return True def SearchEmailResources(self, message_id): - 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)]) - if not mail_id: - return None - address = execute( conn, 'execute', self._dbname, int(self._uid), self._pwd, 'mailgate.message','read',mail_id[0],['model','res_id']) - for key, vals in address.items(): - res_vals.append([key,vals]) - return res_vals - + connector = 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)]) + if not mail_id: + return None + address = execute( conn, 'execute', self._dbname, int(self._uid), self._pwd, 'mailgate.message','read',mail_id[0],['model','res_id']) + for key, vals in address.items(): + res_vals.append([key,vals]) + return res_vals def GetCountry(self, country_search=''): - conn = xmlrpclib.ServerProxy(self._uri+ '/xmlrpc/object') - ids=[] - obj_list=[] - domain = [] - if not country_search.strip() == '': - domain.append(('name','ilike',ustr(country_search))) - ids = execute(conn,'execute',self._dbname,int(self._uid),self._pwd,'res.country','search',domain) - if ids: - ids.sort() - for id in ids: - object = execute(conn,'execute',self._dbname,int(self._uid),self._pwd,'res.country','read',[id],['id','name'])[0] - obj_list.append((object['id'], ustr(object['name']))) - obj_list.sort(lambda x, y: cmp(x[1],y[1])) - return obj_list + conn = xmlrpclib.ServerProxy(self._uri+ '/xmlrpc/object') + ids=[] + obj_list=[] + domain = [] + if not country_search.strip() == '': + domain.append(('name','ilike',ustr(country_search))) + ids = execute(conn,'execute',self._dbname,int(self._uid),self._pwd,'res.country','search',domain) + if ids: + ids.sort() + for id in ids: + object = execute(conn,'execute',self._dbname,int(self._uid),self._pwd,'res.country','read',[id],['id','name'])[0] + obj_list.append((object['id'], ustr(object['name']))) + obj_list.sort(lambda x, y: cmp(x[1],y[1])) + return obj_list def GetStates(self, state_search='', country=None): - conn = xmlrpclib.ServerProxy(self._uri+ '/xmlrpc/object') - ids = [] - c_id = [] - obj_list = [] - domain = [] - if not state_search.strip() == '': - domain.append(('name','ilike',ustr(state_search))) - - if country == None: - ids = execute(conn,'execute',self._dbname,int(self._uid),self._pwd,'res.country.state','search',domain) - if not country == None: - c_id = execute(conn,'execute',self._dbname,int(self._uid),self._pwd,'res.country','search',[('name','=',ustr(country))]) - domain.append(('country_id','=',c_id[0])) - ids = execute(conn,'execute',self._dbname,int(self._uid),self._pwd,'res.country.state','search',domain) - if ids: - ids.sort() - for id in ids: - object = execute(conn,'execute',self._dbname,int(self._uid),self._pwd,'res.country.state','read',[id],['id','name'])[0] - obj_list.append((object['id'], ustr(object['name']))) - obj_list.sort(lambda x, y: cmp(x[1],y[1])) - return obj_list + conn = xmlrpclib.ServerProxy(self._uri+ '/xmlrpc/object') + ids = [] + c_id = [] + obj_list = [] + domain = [] + if not state_search.strip() == '': + domain.append(('name','ilike',ustr(state_search))) + if country == None: + ids = execute(conn,'execute',self._dbname,int(self._uid),self._pwd,'res.country.state','search',domain) + if not country == None: + c_id = execute(conn,'execute',self._dbname,int(self._uid),self._pwd,'res.country','search',[('name','=',ustr(country))]) + domain.append(('country_id','=',c_id[0])) + ids = execute(conn,'execute',self._dbname,int(self._uid),self._pwd,'res.country.state','search',domain) + if ids: + ids.sort() + for id in ids: + object = execute(conn,'execute',self._dbname,int(self._uid),self._pwd,'res.country.state','read',[id],['id','name'])[0] + obj_list.append((object['id'], ustr(object['name']))) + obj_list.sort(lambda x, y: cmp(x[1],y[1])) + return obj_list def FindCountryForState(self, state_search=''): - conn = xmlrpclib.ServerProxy(self._uri+ '/xmlrpc/object') - ids = execute(conn,'execute',self._dbname,int(self._uid),self._pwd,'res.country.state','search',[('name','=',ustr(state_search))]) - if not ids: - return None - object = execute(conn,'execute',self._dbname,int(self._uid),self._pwd,'res.country.state','read',ids)[0] - country = object['country_id'][1] - return country + conn = xmlrpclib.ServerProxy(self._uri+ '/xmlrpc/object') + ids = execute(conn,'execute',self._dbname,int(self._uid),self._pwd,'res.country.state','search',[('name','=',ustr(state_search))]) + if not ids: + return None + object = execute(conn,'execute',self._dbname,int(self._uid),self._pwd,'res.country.state','read',ids)[0] + country = object['country_id'][1] + return country def CreateEmailAttachment(self, rec, mail): - conn = xmlrpclib.ServerProxy(self._uri+ '/xmlrpc/object') + conn = xmlrpclib.ServerProxy(self._uri+ '/xmlrpc/object') obj = rec[0] obj_id = rec[1] res = {} @@ -516,15 +515,15 @@ class XMLRpcConn(object): ls = ['*', '/', '\\', '<', '>', ':', '?', '"', '|', '\t', '\n',':','~'] fn = (mail.Subject).replace(' ','') for c in ls: - fn = fn.replace(c,'') + 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] + 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' f = open(fn,"w") body = mail.Body.encode("utf-8") @@ -539,3 +538,4 @@ class XMLRpcConn(object): res['res_id'] = obj_id id = execute(conn,'execute',self._dbname,int(self._uid),self._pwd,'ir.attachment','create',res) return id + -- cgit v1.2.3 From 35c60188f3188881bceed3035aaf4b6dd1438e5d Mon Sep 17 00:00:00 2001 From: jam-openerp Date: Mon, 15 Nov 2010 17:20:57 +0530 Subject: [IMP]lp:628071 and New Clean File are addded for Plugin bzr revid: jam@tinyerp.com-20101115115057-f3v20p0xqqeryppo --- .../outlook/plugin/openerp-outlook-plugin/addin.py | 140 ++-- .../openerp-outlook-plugin/dialogs/dialog_map.py | 1 - .../dialogs/resources/dialogs.py | 6 +- .../plugin/openerp-outlook-plugin/tiny_xmlrpc.py | 728 ++++++++++----------- 4 files changed, 463 insertions(+), 412 deletions(-) (limited to 'addons/outlook/plugin') diff --git a/addons/outlook/plugin/openerp-outlook-plugin/addin.py b/addons/outlook/plugin/openerp-outlook-plugin/addin.py index a86bcb88e6b..130d8b6e19e 100644 --- a/addons/outlook/plugin/openerp-outlook-plugin/addin.py +++ b/addons/outlook/plugin/openerp-outlook-plugin/addin.py @@ -50,69 +50,121 @@ def GetConn(): d=Dispatch("Python.OpenERP.XMLRpcConn") return d class Configuration: + def Init(self, application): + self.mngr = None + + def Close(self): + self.mngr = None + self.close() + win32ui.MessageBox("Configuration","Configuration") + def OnClick(self, button, cancel): + import win32ui try: - mngr = manager.GetManager() - mngr.ShowManager() + self.mngr = manager.GetManager() + self.mngr.ShowManager() except Exception,e: - win32ui.MessageBox("Fail to Initialize dialog.\n"+str(e),"OpenERP Configuration", win32con.MB_ICONERROR) + win32ui.MessageBox("Fail to Initialize dialog.\n"+str(e),"OpenERP Configuration", win32con.MB_ICONERROR) return cancel # class ViewPartners: + def Init(self, application): + self.mngr = None + self.data = None + self.outlook = None + self.ex= None + + def Close(self): + self.mngr = None + self.data = None + self.outlook = None + self.ex= None + self.close() + win32ui.MessageBox("ViewPartners","ViewPartners") + def OnClick(self, button, cancel): from win32com.client import Dispatch import win32con - mngr = manager.GetManager() - data=mngr.LoadConfig() - outlook = Dispatch("Outlook.Application") - ex = outlook.ActiveExplorer() - if ex: + self.mngr = manager.GetManager() + self.data = self.mngr.LoadConfig() + self.outlook = Dispatch("Outlook.Application") + self.ex = self.outlook.ActiveExplorer() + if self.ex: is_login = str(data['login']) if is_login == 'False': win32ui.MessageBox("Please login to the database first", "OpenERP Connection", win32con.MB_ICONEXCLAMATION) - elif ex.Selection.Count == 1 or ex.Selection.Count == 0: - mngr = manager.GetManager() - mngr.ShowManager("IDD_VIEW_PARTNER_DIALOG") - elif ex.Selection.Count > 1: + elif self.ex.Selection.Count == 1 or ex.Selection.Count == 0: + self.mngr = manager.GetManager() + self.mngr.ShowManager("IDD_VIEW_PARTNER_DIALOG") + elif self.ex.Selection.Count > 1: win32ui.MessageBox("Multiple selection not allowed. Please select only one mail at a time.","Open Contact",win32con.MB_ICONINFORMATION) return cancel # class OpenPartner: - def OnClick(self, button, cancel): - mngr = manager.GetManager() - data=mngr.LoadConfig() - outlook = Dispatch("Outlook.Application") - ex = outlook.ActiveExplorer() - if ex: - is_login = str(data['login']) - if is_login == 'False': - win32ui.MessageBox("Please login to the database first", "OpenERP Connection", win32con.MB_ICONEXCLAMATION) - elif ex.Selection.Count == 1: - mngr = manager.GetManager() - mngr.ShowManager("IDD_OPEN_PARTNER_DIALOG") - elif ex.Selection.Count == 0: - win32ui.MessageBox("No mail selected to push to OpenERP","Push to OpenERP",win32con.MB_ICONINFORMATION) - elif ex.Selection.Count > 1: - win32ui.MessageBox("Multiple selection not allowed. Please select only one mail at a time.","Push to OpenERP",win32con.MB_ICONINFORMATION) - return cancel + def Init(self, application): + self.mngr = None + self.data = None + self.outlook = None + self.ex= None + + def Close(self): + self.mngr = None + self.data = None + self.outlook = None + self.ex= None + self.close() + win32ui.MessageBox("OpenPartner","OpenPartner") + + def OnClick(self, button, cancel): + import win32ui + from manager import ustr + self.mngr = manager.GetManager() + self.data = self.mngr.LoadConfig() + self.outlook = Dispatch("Outlook.Application") + self.ex = self.outlook.ActiveExplorer() + if ex: + is_login = str(data['login']) + if is_login == 'False': + win32ui.MessageBox("Please login to the database first", "OpenERP Connection", win32con.MB_ICONEXCLAMATION) + elif self.ex.Selection.Count == 1: + self.mngr = manager.GetManager() + self.mngr.ShowManager("IDD_OPEN_PARTNER_DIALOG") + elif self.ex.Selection.Count == 0: + win32ui.MessageBox("No mail selected to push to OpenERP","Push to OpenERP",win32con.MB_ICONINFORMATION) + elif self.ex.Selection.Count > 1: + win32ui.MessageBox("Multiple selection not allowed. Please select only one mail at a time.","Push to OpenERP",win32con.MB_ICONINFORMATION) + return cancel # class OpenDocument: + def Init(self, application): + self.mngr = None + self.data = None + self.outlook = None + self.ex= None + + def Close(self): + self.mngr = None + self.data = None + self.outlook = None + self.ex= None + self.close() + win32ui.MessageBox("OpenDocument","OpenDocument") + def OnClick(self, button, cancel): from win32com.client import Dispatch import win32con - import win32ui - mngr = manager.GetManager() - data=mngr.LoadConfig() - outlook = Dispatch("Outlook.Application") - ex = outlook.ActiveExplorer() - if ex: + self.mngr = manager.GetManager() + self.data = self.mngr.LoadConfig() + self.outlook = Dispatch("Outlook.Application") + self.ex = self.outlook.ActiveExplorer() + if self.ex: is_login = str(data['login']) if is_login == 'False': win32ui.MessageBox("Please login to the database first", "OpenERP Connection", win32con.MB_ICONEXCLAMATION) - elif ex.Selection.Count == 1 or ex.Selection.Count == 0: - mngr = manager.GetManager() - mngr.ShowManager("IDD_OPEN_DOCUEMNT_DIALOG") - elif ex.Selection.Count > 1: + elif self.ex.Selection.Count == 1 or ex.Selection.Count == 0: + self.mngr = manager.GetManager() + self.mngr.ShowManager("IDD_OPEN_DOCUEMNT_DIALOG") + elif self.ex.Selection.Count > 1: win32ui.MessageBox("Multiple selection not allowed. Please select only one mail at a time.","Open Document",win32con.MB_ICONINFORMATION) return cancel # @@ -222,18 +274,18 @@ class OutlookAddin: item.TooltipText = "Click to Open Document that has been pushed to server." item.Enabled = True - def OnDisconnection(self, mode, custom): + self.item.close() mngr = manager.GetManager() mngr.config['login'] = False mngr.SaveConfig() - print "OnDisconnection" + pass def OnAddInsUpdate(self, custom): - print "OnAddInsUpdate", custom + pass def OnStartupComplete(self, custom): - print "OnStartupComplete", custom + pass def OnBeginShutdown(self, custom): - print "OnBeginShutdown", custom + pass def GetAppDataPath(self): mngr = manager.GetManager() return mngr.data_directory diff --git a/addons/outlook/plugin/openerp-outlook-plugin/dialogs/dialog_map.py b/addons/outlook/plugin/openerp-outlook-plugin/dialogs/dialog_map.py index c78895e74c1..2dfd0fdba87 100644 --- a/addons/outlook/plugin/openerp-outlook-plugin/dialogs/dialog_map.py +++ b/addons/outlook/plugin/openerp-outlook-plugin/dialogs/dialog_map.py @@ -1412,7 +1412,6 @@ def SerachOpenDocuemnt(txtProcessor,*args): txtProcessor.init_done=True return linktodoc = "" - message_id = None try: session = win32com.client.Dispatch("MAPI.session") diff --git a/addons/outlook/plugin/openerp-outlook-plugin/dialogs/resources/dialogs.py b/addons/outlook/plugin/openerp-outlook-plugin/dialogs/resources/dialogs.py index f63d66274af..323f93e4cc2 100644 --- a/addons/outlook/plugin/openerp-outlook-plugin/dialogs/resources/dialogs.py +++ b/addons/outlook/plugin/openerp-outlook-plugin/dialogs/resources/dialogs.py @@ -1,7 +1,7 @@ -#C:\workspace\openerp-outlook-plugin\dialogs\resources\dialogs.py -#This is a generated file. Please edit C:\workspace\openerp-outlook-plugin\dialogs\resources\dialogs.rc instead. +#C:\workspace\openerp-outlook-plugin-lst\dialogs\resources\dialogs.py +#This is a generated file. Please edit C:\workspace\openerp-outlook-plugin-lst\dialogs\resources\dialogs.rc instead. _rc_size_=15985 -_rc_mtime_=1288860503 +_rc_mtime_=1289450705 class FakeParser: dialogs = {'IDD_OPEN_DOCUEMNT_DIALOG': [['Open Document', (0, 0, 200, 65), -1865940928, 1024, (8, 'Tahoma')], [130, 'Link to Document : (If this link does not opens directly in web browser then copy an the link and paste in web browser.) ', -1, (5, 3, 190, 25), 1342177280], [129, '', 2086, (5, 31, 190, 12), 1350631552], [128, 'Ok', 2, (150, 45, 45, 14), 1342242816]], 'IDD_VIEW_PARTNER_DIALOG': [['Open Contact', (0, 0, 350, 215), -1865940928, 1024, (8, 'Tahoma')], [130, 'Email ID : ', -1, (32, 17, 40, 12), 1342177280], [129, '', 2051, (70, 15, 200, 12), 1350631552], [128, 'Search Contact ', 2052, (280, 15, 60, 14), 1342242816], [130, 'Partner Name : ', -1, (13, 42, 50, 17), 1342177280], [129, '', 2064, (70, 42, 150, 12), 1350568064], [128, 'Search Partner', 2070, (225, 41, 60, 14), 1342242816], [128, 'New Partner', 2093, (290, 41, 50, 14), 1342242816], [128, 'Postal Address ', 2024, (10, 65, 175, 125), 1342177287], [130, 'Contact Name : ', -1, (18, 83, 50, 17), 1342177280], [129, '', 2046, (76, 82, 100, 12), 1350631552], [130, 'Street : ', -1, (18, 97, 50, 17), 1342177280], [129, '', 2053, (76, 96, 100, 12), 1350631552], [130, 'Street2 : ', -1, (18, 112, 50, 17), 1342177280], [129, '', 2054, (76, 111, 100, 12), 1350631552], [130, 'Zip : ', -1, (18, 126, 50, 14), 1342177280], [129, '', 40010, (76, 125, 100, 12), 1350631552], [130, 'City : ', -1, (18, 140, 50, 17), 1342177280], [129, '', 40011, (76, 139, 100, 12), 1350631552], [130, 'Fed. State : ', -1, (18, 154, 50, 17), 1342177280], [129, '', 2062, (76, 153, 54, 12), 1350568064], [128, 'Search', 2104, (135, 153, 40, 12), 1342242816], [130, 'Country :', -1, (18, 169, 35, 17), 1342177280], [129, '', 2063, (76, 168, 54, 12), 1350568064], [128, 'Search', 2105, (135, 168, 40, 12), 1342242816], [128, 'Communication ', 2024, (188, 65, 152, 125), 1342177287], [130, 'Phone : ', -1, (194, 83, 30, 17), 1342177280], [129, '', 2048, (224, 82, 100, 12), 1350631552], [130, 'Mobile : ', -1, (194, 97, 30, 17), 1342177280], [129, '', 2050, (224, 96, 100, 12), 1350631552], [130, 'Email : ', -1, (194, 111, 30, 17), 1342177280], [129, '', 2058, (224, 110, 100, 12), 1350568064], [130, 'Fax : ', -1, (194, 125, 30, 17), 1342177280], [129, '', 2047, (224, 124, 100, 12), 1350631552], [128, 'Create a New Contact', 2071, (124, 195, 82, 14), 1342242816], [128, 'Save', 2059, (213, 195, 60, 14), 1342242816], [128, 'Cancel', 2, (281, 195, 60, 14), 1342242816]], 'IDD_OPEN_PARTNER_DIALOG': [['Open Partner', (0, 0, 200, 65), -1865940928, 1024, (8, 'Tahoma')], [130, 'Link to Partner : (If this link does not opens directly in web browser then copy an the link and paste in web browser.) ', -1, (5, 3, 190, 25), 1342177280], [129, '', 2085, (5, 31, 190, 12), 1350631552], [128, 'Ok', 2, (150, 45, 45, 13), 1342242816]], 'IDD_SELECT_STATE': [['Search Fed. State', (0, 0, 220, 250), -1865940928, 1024, (8, 'Tahoma')], [130, 'Enter Name : ', -1, (8, 12, 80, 17), 1342177280], [129, '', 2100, (55, 10, 100, 12), 1350631552], [128, 'Search', 40012, (160, 10, 50, 14), 1342242816], ['SysListView32', 'List1', 2101, (8, 40, 200, 185), 1353711657], [128, 'Select', 2102, (170, 230, 40, 14), 1342242816]], 'IDD_GENERAL': [['Connection Parameters', (0, 0, 430, 210), 1355284544, None, (8, 'Tahoma')], [128, 'Connection Parameters', 2024, (10, 10, 250, 130), 1342177287], [130, 'Server : ', -1, (30, 30, 100, 17), 1342177280], [129, '', 2003, (85, 30, 120, 12), 1350633472], [128, 'Change', 2021, (210, 30, 30, 13), 1342242816], [130, 'Database : ', -1, (30, 50, 100, 17), 1342177280], [133, '', 2004, (85, 50, 154, 40), 1344339971], [130, 'Username : ', -1, (30, 70, 100, 17), 1342177280], [129, '', 2005, (85, 70, 154, 12), 1350631552], [130, 'Password : ', -1, (30, 90, 100, 17), 1342177280], [129, '', 2006, (85, 90, 154, 12), 1350631584], [128, 'Connect', 2007, (179, 110, 60, 13), 1342242816], [128, 'WebServer Parameters', 2024, (270, 10, 150, 130), 1342177287], [130, 'Server : ', -1, (280, 30, 50, 15), 1342177280], [129, '', 2080, (310, 29, 90, 12), 1350568064], [128, 'Change', 2082, (295, 50, 50, 12), 1342242816], [128, 'Connect', 2083, (350, 50, 50, 12), 1342242816]], 'IDD_OBJECT_SETTINGS': [['Documents Setting', (0, 0, 430, 210), 1355284672, 1024, (8, 'Tahoma')], [128, 'Document Attributes', 2024, (2, 2, 343, 32), 1342177287], [130, 'Title:', -1, (5, 16, 30, 17), 1342177280], [129, '', 2013, (22, 14, 57, 12), 1350631552], [130, 'Document Name:', -1, (83, 16, 60, 17), 1342177280], [129, '', 2014, (138, 14, 57, 12), 1350631552], [130, 'Image:', -1, (200, 16, 22, 17), 1342177280], [129, '', 2015, (223, 14, 57, 12), 1350631552], [128, 'Load Image', 2010, (289, 13, 50, 15), 1342242816], [128, 'Add', 2011, (350, 13, 38, 15), 1342242816], [128, 'Delete', 2012, (392, 13, 38, 15), 1342242816], ['SysListView32', 'List1', 2016, (8, 40, 535, 160), 1353711657]], 'IDD_NEW_PARTNER_DIALOG': [['Create a New Partner', (0, 0, 140, 40), -1865940928, 1024, (8, 'Tahoma')], [130, 'Name : ', -1, (5, 3, 100, 17), 1342177280], [129, '', 2036, (40, 3, 94, 12), 1350631552], [128, 'Cancel', 2, (90, 22, 45, 14), 1342242816], [128, 'Save', 2035, (40, 22, 45, 14), 1342242817]], 'IDD_MANAGER': [['OpenERP Configuration', (0, 0, 460, 260), -1865940800, None, (8, 'Tahoma')], [128, 'Close', 2008, (400, 239, 50, 14), 1342177281], ['SysTabControl32', '', 1068, (8, 7, 440, 228), 1342177280], ['SysListView32', '', 2016, (0, 0, 0, 0), 1353711657]], 'IDD_WEB_SERVER_PORT_DIALOG': [['OpenERP Connection', (0, 0, 160, 55), -1865940928, 1024, (8, 'Tahoma')], [130, 'Server : ', -1, (5, 3, 150, 17), 1342177280], [129, '', 2089, (40, 3, 100, 12), 1350631552], [130, 'Port : ', -1, (5, 18, 100, 17), 1342177280], [129, '', 2090, (40, 18, 100, 12), 1350631552], [128, 'Close', 2, (110, 35, 45, 14), 1342242816], [128, 'OK', 2091, (60, 35, 45, 14), 1342242817]], 'IDD_ABOUT': [['About', (0, 0, 430, 210), 1355284672, 1024, (8, 'Tahoma')], [128, 'About Plugin', -1, (7, 3, 422, 200), 1342177287], [130, '1062', 1062, (60, 30, 20, 20), 1342179342], [130, '', 2028, (80, 90, 300, 100), 1342177280]], 'IDD_NEW_CONTACT_DIALOG': [['Create a New Contact', (0, 0, 350, 180), -1865940928, 1024, (8, 'Tahoma')], [130, 'Select Partner : ', -1, (13, 20, 50, 17), 1342177280], [129, '', 2079, (70, 18, 150, 12), 1350568064], [128, 'Search Partner', 2033, (225, 17, 60, 14), 1342242816], [128, 'New Partner', 2092, (290, 17, 50, 14), 1342242816], [128, 'Postal Address ', 2024, (10, 35, 175, 123), 1342177287], [130, 'Contact Name : ', -1, (18, 53, 100, 17), 1342177280], [129, '', 40005, (76, 52, 100, 12), 1350631552], [130, 'Street : ', -1, (18, 67, 40, 17), 1342177280], [129, '', 2062, (76, 66, 100, 12), 1350631552], [130, 'Street2 : ', -1, (18, 81, 40, 17), 1342177280], [129, '', 2063, (76, 80, 100, 12), 1350631552], [130, 'Zip : ', -1, (18, 94, 50, 17), 1342177280], [129, '', 2068, (76, 93, 100, 12), 1350631552], [130, 'City : ', -1, (18, 106, 50, 17), 1342177280], [129, '', 2067, (76, 107, 100, 12), 1350631552], [130, 'Fed. State : ', -1, (18, 134, 50, 15), 1342177280], [129, '', 2106, (76, 135, 54, 12), 1350568064], [128, 'Search', 2107, (135, 136, 40, 12), 1342242816], [130, 'Country :', -1, (18, 121, 35, 15), 1342177280], [129, '', 2108, (76, 122, 54, 12), 1350568064], [128, 'Search', 2109, (135, 121, 40, 12), 1342242816], [128, 'Communication ', 2024, (188, 35, 150, 123), 1342177287], [130, 'Office : ', -1, (194, 53, 30, 17), 1342177280], [129, '', 40006, (224, 52, 100, 12), 1350631552], [130, 'Mobile : ', -1, (194, 67, 30, 17), 1342177280], [129, '', 40007, (224, 66, 100, 12), 1350631552], [130, 'Fax : ', -1, (194, 81, 30, 17), 1342177280], [129, '', 2066, (224, 80, 100, 12), 1350631552], [130, 'Email : ', -1, (194, 95, 30, 17), 1342177280], [129, '', 40008, (224, 94, 100, 12), 1350631552], [128, 'Cancel', 2, (290, 162, 45, 13), 1342242816], [128, 'Save', 40009, (240, 162, 45, 13), 1342242816]], 'IDD_SERVER_PORT_DIALOG': [['OpenERP Connection', (0, 0, 160, 55), -1865940928, 1024, (8, 'Tahoma')], [130, 'Server : ', -1, (5, 3, 150, 17), 1342177280], [129, '', 2001, (40, 3, 100, 12), 1350631552], [130, 'Port : ', -1, (5, 18, 100, 17), 1342177280], [129, '', 2002, (40, 18, 100, 12), 1350631552], [128, 'Close', 2, (110, 35, 45, 14), 1342242816], [128, 'OK', 1, (60, 35, 45, 14), 1342242817]], 'IDD_SELECT_PARTNER': [['Search Partner', (0, 0, 220, 250), -1865940928, 1024, (8, 'Tahoma')], [130, 'Enter Name : ', -1, (8, 12, 80, 17), 1342177280], [129, '', 2076, (55, 10, 100, 12), 1350631552], [128, 'Search', 2077, (160, 10, 50, 14), 1342242816], ['SysListView32', 'List1', 2072, (8, 40, 200, 185), 1353711657], [128, 'Create New Partner', 2078, (10, 230, 100, 14), 1342242816], [128, 'Select', 2075, (170, 230, 40, 14), 1342242816]], 'IDD_SYNC': [['Push to OpenERP', (0, 0, 470, 320), -1865940928, 1024, (8, 'Tahoma')], [128, 'Link to an Existing Documents ', 2024, (8, 5, 250, 290), 1342242823], [130, 'Search : ', -1, (15, 17, 40, 12), 1342177280], [129, '', 40003, (60, 15, 120, 12), 1350631552], [128, 'Search', 40004, (187, 15, 40, 14), 1342242816], [130, 'Documents : ', -1, (15, 140, 100, 14), 1342177280], ['SysListView32', 'List1', 2026, (15, 150, 234, 110), 1350631433], [128, 'Push', 2019, (160, 270, 85, 14), 1342242816], [128, ' Create a New Document ', 2024, (263, 5, 202, 100), 1342242823], [130, 'Type of Document : ', -1, (266, 25, 100, 12), 1342177280], [133, '', 2025, (332, 24, 75, 45), 1344339971], [128, 'Create', 2020, (412, 23, 50, 14), 1342242816], [128, ' Create a New Contact ', 2024, (263, 110, 202, 185), 1342242823], [130, 'Create a New Contact : ', -1, (280, 140, 100, 12), 1342177280], [128, 'Create Contact', 2018, (360, 138, 60, 14), 1342242816], [128, 'Close', 2, (385, 300, 60, 14), 1342242816]], 'IDD_SELECT_COUNTRY': [['Search Country', (0, 0, 220, 250), -1865940928, 1024, (8, 'Tahoma')], [130, 'Enter Name : ', -1, (8, 12, 80, 17), 1342177280], [129, '', 2095, (55, 10, 100, 12), 1350631552], [128, 'Search', 2098, (160, 10, 50, 14), 1342242816], ['SysListView32', 'List1', 2096, (8, 40, 200, 185), 1353711657], [128, 'Select', 2097, (170, 230, 40, 14), 1342242816]]} ids = {'IDC_BUT_DEL_OBJECT': 2012, 'IDD_OPEN_PARTNER_DIALOG': 2084, 'IDD_SELECT_STATE': 2099, 'IDC_DELAY1_SLIDER': 1056, 'IDC_PROGRESS': 1000, 'IDD_MANAGER': 101, 'IDC_ABOUT': 2028, 'IDD_DIAGNOSTIC': 113, 'IDET_PARTNER_COUNTRY': 2063, 'IDD_TRAINING': 102, 'ID_CONTACT_EMAIL_TEXT': 40008, 'IDC_DELAY2_TEXT': 1059, 'IDC_DELAY1_TEXT': 1057, 'IDD_WIZARD': 114, 'IDC_CHKBX': 2023, 'IDC_STATIC_HAM': 1002, 'IDC_PROGRESS_TEXT': 1001, 'IDR_XMLS_PROTOCOL': 2042, 'IDD_GENERAL': 108, 'IDD_ABOUT': 2027, 'IDD_SYNC': 40002, 'IDC_TAB': 1068, 'IDC_FOLDER_UNSURE': 1033, '_APS_NEXT_SYMED_VALUE': 101, 'IDC_VERBOSE_LOG': 1061, 'IDC_EDIT1': 1094, 'IDC_BROWSE': 1037, 'ID_DB_DROPDOWNLIST': 2004, 'IDC_BACK_BTN': 1069, 'ID_CONTACT_NAME_TEXT': 40005, 'IDPB_PARTNER_SEARCH': 2077, 'IDD_WIZARD_FINISHED_UNCONFIGURED': 119, 'IDC_ACTION_CERTAIN': 1025, 'IDC_BUT_ACT_ALL': 1019, 'IDD_FILTER_NOW': 104, 'IDET_WED_SERVER': 2080, 'ID_WEB_OK': 2091, 'ID_PROTOCOL_GRP': 2040, 'IDC_HEADER': 2017, 'IDC_MARK_SPAM_AS_READ': 1047, 'IDPB_NEW_PARTNER_BUTTON': 2092, 'ID_PARTNER_NAME_TEXT': 2036, 'IDC_RECOVER_RS': 1075, 'IDC_NAME_LIST1': 2037, 'ID_CONTACT_OFFICE_TEXT': 40006, 'IDC_STATIC': -1, 'IDC_PAGE_PLACEHOLDER': 1078, 'IDC_BROWSE_WATCH': 1039, 'IDET_ZIP': 40010, 'IDET_PARTNER_CITY': 40011, 'IDET_PARTNER_LINK_TEXT': 2085, 'IDC_FOLDER_HAM': 1083, 'IDC_LIST_COUNTRY': 2096, 'IDD_WIZARD_FOLDERS_REST': 117, 'IDC_SHOW_DATA_FOLDER': 1071, 'IDC_BUT_ACT_SCORE': 1018, 'IDET_STATE_SEARCH_NAME': 2100, 'IDET_WEB_SERVER': 2089, '_APS_NEXT_RESOURCE_VALUE': 128, 'ID_SET_WEB_CONNECTION': 2082, 'IDC_LIST_STATE': 2101, 'IDC_CONTACT_LIST': 2029, 'IDC_SLIDER_CERTAIN': 1023, 'IDET_PARTNER_STREET': 2053, 'IDC_BUT_UNREAD': 1020, 'ID_PARTNER_DROPDOWNLIST': 2032, 'ID_COUNTRY_DROPLIST': 2065, 'IDC_BUT_ABOUT': 1017, 'IDC_BUT_RESCORE': 1008, 'IDC_BUT_SEARCHSUB': 1041, 'IDC_BUT_TRAIN_FROM_SPAM_FOLDER': 1010, 'IDET_PARTNER_MOBILENO': 2050, 'ID_CONTACT_MOBILE_TEXT': 40007, 'IDD_VIEW_PARTNER_DIALOG': 2044, 'IDD_WIZARD_FOLDERS_TRAIN': 120, 'IDC_BUT_FILTER_ENABLE': 1013, 'IDPB_WEB_CONNECTION': 2083, 'IDC_ABOUT_BTN': 1072, 'IDD_WIZARD_FINISHED_TRAINED': 122, 'ID_SERVER': 2001, 'IDD_SELECT_PARTNER': 2073, 'IDET_NC_PARTNER_STATE': 2106, 'IDD_FOLDER_SELECTOR': 105, 'IDC_BUT_SET_SERVER_PORT': 2021, 'ID_DONE': 2008, 'IDC_LIST_FOLDERS': 1040, 'IDC_IMAGE_PATH': 2015, 'IDB_SBWIZLOGO': 125, 'IDB_OPENERPLOGO': 1062, 'ID_ZIP_TEXT': 2068, 'IDEB_OPENDOC_LINK_TEXT': 2086, 'IDD_NEW_PARTNER_DIALOG': 2034, 'ID_PARTNER_DROPLIST': 2069, 'IDC_BUT_VIEW_LOG': 1093, 'IDC_STATUS2': 1044, 'IDC_STATUS1': 1043, 'IDCANCEL': 2, 'IDC_BROWSE_HAM': 1004, 'ID_BUT_TESTCONNECTION': 2007, 'IDR_NETRPC_PROTOCOL': 2043, 'IDC_BROWSE_SPAM': 1005, 'IDD_OPEN_DOCUEMNT_DIALOG': 2087, 'IDD_WIZARD_FINISHED_UNTRAINED': 116, 'IDC_MARK_UNSURE_AS_READ': 1051, 'IDPB_SEARCH_COUNTRY1': 2105, 'ID_PARTNER_CITY_TEXT': 2067, 'IDC_BUT_WIZARD': 1070, 'IDC_VERSION': 1009, 'ID_NEW_PARTNER_BUTTON': 2033, 'IDC_FOLDER_NAMES': 1036, 'ID_ATT_METHOD_DROPDOWNLIST': 2025, 'IDC_BUT_TIMER_ENABLED': 1091, 'IDPB_WRITE_CHANGES': 2059, 'IDC_SLIDER_UNSURE': 1029, 'IDC_BUT_NEW': 1046, 'IDC_FOLDER_WATCH': 1038, 'IDPB_CREATE_NEW_PARTNER': 2078, 'IDC_BUT_UNTRAINED': 1088, 'IDC_STATIC_SPAM': 1003, 'IDD_NEW_CONTACT_DIALOG': 2031, 'IDC_EDIT_UNSURE': 1030, 'IDC_BUT_CLEARALL': 1042, 'IDC_BUT_UNSEEN': 1021, 'IDC_OBJECT_NAME': 2014, 'IDD_WIZARD_FOLDERS_WATCH': 118, 'IDPB_SEARCH_STATE': 2103, 'IDET_COUNTRY_SEARCH_NAME': 2095, 'IDC_BUT_SAVE_OBJECT': 2011, 'ID_FED_STATE_DROPLIST': 2064, 'ID_ALL_COUNTRY_DROPDOWNLIST': 2061, 'IDC_EDIT_CERTAIN': 1024, 'IDC_BUT_FILTER_DEFINE': 1016, 'ID_NEW_PART_BUTTON': 2070, 'ID_FAX_TEXT': 2066, 'IDD_WIZARD_TRAINING_IS_IMPORTANT': 123, 'ID_ALL_STATE_DROPDOWNLIST': 2060, 'IDPB_SEARCH_STATE1': 2104, 'IDC_INBOX_TIMER_ONLY': 1060, 'IDPB_SEARCH_PARTNER': 2052, 'ID_USERNAME': 2005, '_APS_NEXT_CONTROL_VALUE': 1096, 'IDC_WIZ_GRAPHIC': 1092, 'IDD_OBJECT_SETTINGS': 2009, 'IDD_FILTER_UNSURE': 111, 'IDC_DEL_SPAM_RS': 1074, 'IDD_SELECT_COUNTRY': 2094, 'ID_SERVER_PORT': 2003, 'IDR_XML_PROTOCOL': 2041, 'IDET_PARTNER_OFFICENO': 2048, 'IDB_FOLDERS': 127, 'IDC_BUT_PREPARATION': 1081, 'ID_STREET2_TEXT': 2063, 'IDC_DELAY2_SLIDER': 1058, 'IDET_PARTNER': 2064, 'IDC_SAVE_SPAM_SCORE': 1048, 'IDC_OBJECT_TITLE': 2013, 'IDC_FOLDER_CERTAIN': 1027, 'IDET_WEB_PORT': 2090, 'IDC_BROWSE_UNSURE': 1034, 'IDC_STATISTICS': 1095, 'IDPB_STATE_SEARCH': 40012, 'ID_MAKE_ATTACHMENT': 2019, 'IDC_BUT_LOAD_IMAGE': 2010, 'IDC_NAME_LIST': 2026, 'IDC_BUT_TRAIN_TO_SPAM_FOLDER': 1011, 'IDET_PARTNER_SEARCH_NAME': 2076, 'IDC_BUT_RESET': 1073, 'ID_SEARCH': 40004, 'IDET_PARTNER_CONTACT_NAME': 2046, 'IDPB_SELECT_STATE': 2102, 'IDC_ACTION_UNSURE': 1031, 'IDD_WIZARD_TRAIN': 121, 'IDC_STATIC_GROUP': 2024, 'IDPB_NEWPARTNER_BUTTON': 2071, 'ID_PARTNER_TEXT': 2079, 'IDD_WIZARD_FINISHED_TRAIN_LATER': 124, 'IDET_PARTNER_NAME': 2045, 'IDPB_NEW_PART_BUTTON': 2093, 'IDC_BUT_REBUILD': 1007, 'IDET_PARTNER_STREET2': 2054, 'IDPB_SEARCH_COUNTRY': 2098, 'ID_SAVE_PARTNER_BUTTON': 2035, 'IDPB_SELECT_PARTNER': 2075, 'ID_STREET_TEXT': 2062, '_APS_NEXT_COMMAND_VALUE': 40001, 'IDET_SEARCH_PARTNER': 2051, 'IDC_LIST_PARTNER': 2072, 'IDD_WEB_SERVER_PORT_DIALOG': 2088, 'ID_PORT': 2002, 'IDD_SERVER_PORT_DIALOG': 2022, 'IDET_PARTNER_STATE': 2062, 'IDPB_SELECT_COUNTRY': 2097, 'ID_SEARCH_TEXT': 40003, 'IDET_NC_PARTNER_COUNTRY': 2108, 'ID_CREATE_CONTACT': 2018, 'IDC_FORWARD_BTN': 1077, 'IDC_TRAINING_STATUS': 1035, 'IDD_WIZARD_WELCOME': 115, 'IDET_PARTNER_FAX': 2058, 'IDC_BUT_TRAIN': 1089, 'IDC_LIST': 2016, 'ID_CREATE_CASE': 2020, 'IDET_PARTNER_EMAIL': 2047, 'IDC_START': 1006, 'IDD_FILTER': 103, 'IDC_RELOAD': 2038, 'ID_PASSWORD': 2006, 'ID_NAME_TEXT': 2030, 'IDC_FILTER_STATUS': 1014, 'IDPB_NC_SEARCH_STATE1': 2107, 'ID_CONTACT_SAVE_BUTTON': 40009, 'IDOK': 1, 'IDC_BROWSE_CERTAIN': 1028, 'IDC_BUT_SHOW_DIAGNOSTICS': 1080, 'IDC_BUT_TRAIN_NOW': 1012, 'IDPB_NC_SEARCH_COUNTRY1': 2109} diff --git a/addons/outlook/plugin/openerp-outlook-plugin/tiny_xmlrpc.py b/addons/outlook/plugin/openerp-outlook-plugin/tiny_xmlrpc.py index b4cb250ba1d..199b6518d7f 100644 --- a/addons/outlook/plugin/openerp-outlook-plugin/tiny_xmlrpc.py +++ b/addons/outlook/plugin/openerp-outlook-plugin/tiny_xmlrpc.py @@ -27,13 +27,11 @@ import time from manager import ustr from win32com.mapi import mapitags import pythoncom -import win32com +import win32com import win32ui - waittime = 10 wait_count = 0 wait_limit = 12 - def execute(connector, method, *args): global wait_count res = False @@ -82,431 +80,434 @@ class XMLRpcConn(object): self.protocol=None def getitem(self, attrib): - v=self.__getattribute__(attrib) - return str(v) + v=self.__getattribute__(attrib) + return str(v) def setitem(self, attrib, value): - return self.__setattr__(attrib, value) + return self.__setattr__(attrib, value) def GetDBList(self): - conn = xmlrpclib.ServerProxy(self._uri + '/xmlrpc/db') - try: - db_list = execute(conn, 'list') - if db_list == False: - self._running=False - return [] - else: - self._running=True - except: - db_list=-1 - self._running=True - return db_list + conn = xmlrpclib.ServerProxy(self._uri + '/xmlrpc/db') + try: + db_list = execute(conn, 'list') + if db_list == False: + self._running=False + return [] + else: + self._running=True + except: + db_list=-1 + self._running=True + return db_list def login(self,dbname, user, pwd): - self._dbname = dbname - self._uname = user - self._pwd = pwd - conn = xmlrpclib.ServerProxy(str(self._uri) + '/xmlrpc/common') - uid = execute(conn,'login',dbname, ustr(user), ustr(pwd)) - return uid + self._dbname = dbname + self._uname = user + self._pwd = pwd + conn = xmlrpclib.ServerProxy(str(self._uri) + '/xmlrpc/common') + uid = execute(conn,'login',dbname, ustr(user), ustr(pwd)) + return uid def GetAllObjects(self): - conn = xmlrpclib.ServerProxy(self._uri+ '/xmlrpc/object') - ids = execute(conn,'execute',self._dbname,int(self._uid),self._pwd,'ir.model','search',[]) - objects = execute(conn,'execute',self._dbname,int(self._uid),self._pwd,'ir.model','read',ids,['model']) - obj_list = [item['model'] for item in objects] - return obj_list + conn = xmlrpclib.ServerProxy(self._uri+ '/xmlrpc/object') + ids = execute(conn,'execute',self._dbname,int(self._uid),self._pwd,'ir.model','search',[]) + objects = execute(conn,'execute',self._dbname,int(self._uid),self._pwd,'ir.model','read',ids,['model']) + obj_list = [item['model'] for item in objects] + return obj_list def GetObjList(self): - self._obj_list=list(self._obj_list) - self._obj_list.sort(reverse=True) - return self._obj_list + self._obj_list=list(self._obj_list) + self._obj_list.sort(reverse=True) + return self._obj_list def InsertObj(self, obj_title,obj_name,image_path): - self._obj_list=list(self._obj_list) - self._obj_list.append((obj_title,obj_name,ustr(image_path))) - self._obj_list.sort(reverse=True) + self._obj_list=list(self._obj_list) + self._obj_list.append((obj_title,obj_name,ustr(image_path))) + self._obj_list.sort(reverse=True) def DeleteObject(self,sel_text): - self._obj_list=list(self._obj_list) - for obj in self._obj_list: - if obj[0] == sel_text: - self._obj_list.remove(obj) - break + self._obj_list=list(self._obj_list) + for obj in self._obj_list: + if obj[0] == sel_text: + self._obj_list.remove(obj) + break def ArchiveToOpenERP(self, recs, mail): - import win32con - conn = xmlrpclib.ServerProxy(self._uri + '/xmlrpc/object') - flag = False - new_msg = ext_msg ="" - message_id = referances = None - try: - session = win32com.client.Dispatch("MAPI.session") - session.Logon('Outlook') - objMessage = session.GetMessage(mail.EntryID, mail.Parent.StoreID) - objFields = objMessage.Fields - strheader = objFields.Item(mapitags.PR_TRANSPORT_MESSAGE_HEADERS) - strheader = ustr(strheader).encode('iso-8859-1') - headers = {} - strheader = strheader.replace("\n ", " ").splitlines() - for line in strheader: - split_here = line.find(":") - headers[line[:split_here]] = line[split_here:] - temp1 = headers.get('Message-ID') - temp2 = headers.get('Message-Id') - referances = headers.get('References') - if temp1 == None: message_id = temp2 - if temp2 == None: message_id = temp1 - startCut = message_id.find("<") - endCut = message_id.find(">") - message_id = message_id[startCut:endCut+1] - if not referances == None: - startCut = referances.find("<") - endCut = referances.find(">") - referances = referances[startCut:endCut+1] - except Exception,e: - win32ui.MessageBox(str(e),"Archive To OpenERP") - return - attachments=mail.Attachments - for rec in recs: #[('res.partner', 3, 'Agrolait')] + import win32con + conn = xmlrpclib.ServerProxy(self._uri + '/xmlrpc/object') + flag = False + new_msg = ext_msg ="" + message_id = referances = None + try: + session = win32com.client.Dispatch("MAPI.session") + session.Logon('Outlook') + objMessage = session.GetMessage(mail.EntryID, mail.Parent.StoreID) + objFields = objMessage.Fields + strheader = objFields.Item(mapitags.PR_TRANSPORT_MESSAGE_HEADERS) + strheader = ustr(strheader).encode('iso-8859-1') + headers = {} + strheader = strheader.replace("\n ", " ").splitlines() + for line in strheader: + split_here = line.find(":") + headers[line[:split_here]] = line[split_here:] + temp1 = headers.get('Message-ID') + temp2 = headers.get('Message-Id') + referances = headers.get('References') + if temp1 == None: message_id = temp2 + if temp2 == None: message_id = temp1 + startCut = message_id.find("<") + endCut = message_id.find(">") + message_id = message_id[startCut:endCut+1] + if not referances == None: + startCut = referances.find("<") + endCut = referances.find(">") + referances = referances[startCut:endCut+1] + except Exception,e: + win32ui.MessageBox(str(e),"Archive To OpenERP") + return + attachments=mail.Attachments + for rec in recs: #[('res.partner', 3, 'Agrolait')] 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')]) 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 + 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)]) 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) - flag = True - continue + 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) + flag = True + continue msg = { - 'subject':mail.Subject, - 'date':str(mail.ReceivedTime), - 'body':mail.Body, - 'cc':mail.CC, - 'from':mail.SenderEmailAddress, - 'to':mail.To, - 'message-id':message_id, - 'references':ustr(referances), + 'subject':mail.Subject, + 'date':str(mail.ReceivedTime), + 'body':mail.Body, + 'cc':mail.CC, + 'from':mail.SenderEmailAddress, + 'to':mail.To, + 'message-id':message_id, + 'references':ustr(referances), } obj_list= ['crm.lead','project.issue','hr.applicant','res.partner'] if rec[0] not in obj_list: ids = self.CreateEmailAttachment(rec,mail) result = {} if attachments: - result = self.MakeAttachment([rec], mail) + 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) new_msg += """- {0} : {1}\n""".format(object_name,str(rec[2])) flag = True - if flag: - t = """Mail archived Successfully with attachments.\n"""+ext_msg - t += "\n"+new_msg - win32ui.MessageBox(t,"Archived to OpenERP",win32con.MB_ICONINFORMATION) - return flag + + if flag: + t = """Mail archived Successfully with attachments.\n"""+ext_msg + t += "\n"+new_msg + win32ui.MessageBox(t,"Archived to OpenERP",win32con.MB_ICONINFORMATION) + return flag def IsCRMInstalled(self): - conn = xmlrpclib.ServerProxy(self._uri+ '/xmlrpc/object') - id = execute(conn,'execute',self._dbname,int(self._uid),self._pwd,'ir.model','search',[('model','=','crm.lead')]) - return id + conn = xmlrpclib.ServerProxy(self._uri+ '/xmlrpc/object') + id = execute(conn,'execute',self._dbname,int(self._uid),self._pwd,'ir.model','search',[('model','=','crm.lead')]) + return id def GetCSList(self): - conn = xmlrpclib.ServerProxy(self._uri+ '/xmlrpc/object') - ids = execute(conn,'execute',self._dbname,int(int(self._uid)),self._pwd,'crm.case.section','search',[]) - objects = execute(conn,'execute',self._dbname,int(self._uid),self._pwd,'crm.case.section','read',ids,['name']) - obj_list = [ustr(item['name']).encode('iso-8859-1') for item in objects] - return obj_list + conn = xmlrpclib.ServerProxy(self._uri+ '/xmlrpc/object') + ids = execute(conn,'execute',self._dbname,int(int(self._uid)),self._pwd,'crm.case.section','search',[]) + objects = execute(conn,'execute',self._dbname,int(self._uid),self._pwd,'crm.case.section','read',ids,['name']) + obj_list = [ustr(item['name']).encode('iso-8859-1') for item in objects] + return obj_list def GetPartners(self, search_partner=''): - conn = xmlrpclib.ServerProxy(self._uri+ '/xmlrpc/object') - ids=[] - obj_list=[] - domain = [] - if not search_partner.strip() == '': - domain.append(('name','ilike',ustr(search_partner))) - ids = execute(conn,'execute',self._dbname,int(self._uid),self._pwd,'res.partner','search',domain) - if ids: - ids.sort() - obj_list.append((-999, ustr(''))) - for id in ids: - object = execute(conn,'execute',self._dbname,int(self._uid),self._pwd,'res.partner','read',[id],['id','name'])[0] - obj_list.append((object['id'], ustr(object['name']))) - obj_list.sort(lambda x, y: cmp(x[1],y[1])) - return obj_list + conn = xmlrpclib.ServerProxy(self._uri+ '/xmlrpc/object') + ids=[] + obj_list=[] + domain = [] + if not search_partner.strip() == '': + domain.append(('name','ilike',ustr(search_partner))) + ids = execute(conn,'execute',self._dbname,int(self._uid),self._pwd,'res.partner','search',domain) + if ids: + ids.sort() + obj_list.append((-999, ustr(''))) + for id in ids: + object = execute(conn,'execute',self._dbname,int(self._uid),self._pwd,'res.partner','read',[id],['id','name'])[0] + obj_list.append((object['id'], ustr(object['name']))) + obj_list.sort(lambda x, y: cmp(x[1],y[1])) + return obj_list def GetObjectItems(self, search_list=[], search_text=''): - res = [] - conn = xmlrpclib.ServerProxy(self._uri+ '/xmlrpc/object') - for obj in search_list: - object_ids = execute ( conn,'execute',self._dbname,int(self._uid),self._pwd,'ir.model','search',[('model','=',obj)]) - object_name = execute( conn,'execute',self._dbname,int(self._uid),self._pwd,'ir.model','read',object_ids,['name'])[0]['name'] - if obj == "res.partner.address": - ids = execute(conn,'execute',self._dbname,int(self._uid),self._pwd,obj,'search',['|',('name','ilike',ustr(search_text)),('email','ilike',ustr(search_text))]) - recs = execute(conn,'execute',self._dbname,int(self._uid),self._pwd,obj,'read',ids,['id','name','street','city']) - for rec in recs: - name = ustr(rec['name']) - if rec['street']: - name += ', ' + ustr(rec['street']) - if rec['city']: - name += ', ' + ustr(rec['city']) - res.append((obj,rec['id'],name,object_name)) - else: - ids = execute(conn,'execute',self._dbname,int(self._uid),self._pwd,obj,'search',[('name','ilike',ustr(search_text))]) - recs = execute(conn,'execute',self._dbname,int(self._uid),self._pwd,obj,'read',ids,['id','name']) - for rec in recs: - name = ustr(rec['name']) - res.append((obj,rec['id'],name,object_name)) - return res_id + res = [] + conn = xmlrpclib.ServerProxy(self._uri+ '/xmlrpc/object') + for obj in search_list: + object_ids = execute ( conn,'execute',self._dbname,int(self._uid),self._pwd,'ir.model','search',[('model','=',obj)]) + object_name = execute( conn,'execute',self._dbname,int(self._uid),self._pwd,'ir.model','read',object_ids,['name'])[0]['name'] + if obj == "res.partner.address": + ids = execute(conn,'execute',self._dbname,int(self._uid),self._pwd,obj,'search',['|',('name','ilike',ustr(search_text)),('email','ilike',ustr(search_text))]) + recs = execute(conn,'execute',self._dbname,int(self._uid),self._pwd,obj,'read',ids,['id','name','street','city']) + for rec in recs: + name = ustr(rec['name']) + if rec['street']: + name += ', ' + ustr(rec['street']) + if rec['city']: + name += ', ' + ustr(rec['city']) + res.append((obj,rec['id'],name,object_name)) + else: + ids = execute(conn,'execute',self._dbname,int(self._uid),self._pwd,obj,'search',[('name','ilike',ustr(search_text))]) + recs = execute(conn,'execute',self._dbname,int(self._uid),self._pwd,obj,'read',ids,['id','name']) + for rec in recs: + name = ustr(rec['name']) + res.append((obj,rec['id'],name,object_name)) + return res def CreateCase(self, section, mail, partner_ids, with_attachments=True): - import eml - flag = False - id = -1 - try: - conn = xmlrpclib.ServerProxy(self._uri+ '/xmlrpc/object') - email=eml.generateEML(mail) - message_id = None - session = win32com.client.Dispatch("MAPI.session") - session.Logon('Outlook') - objMessage = session.GetMessage(mail.EntryID, mail.Parent.StoreID) - objFields = objMessage.Fields - strheader = objFields.Item(mapitags.PR_TRANSPORT_MESSAGE_HEADERS) - strheader = ustr(strheader).encode('iso-8859-1') - headers = {} - strheader = strheader.replace("\n ", " ").splitlines() - for line in strheader: - split_here = line.find(":") - headers[line[:split_here]] = line[split_here:] - temp1 = headers.get('Message-ID') - temp2 = headers.get('Message-Id') - if temp1 == None: message_id = temp2 - if temp2 == None: message_id = temp1 - startCut = message_id.find("<") - 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)) - if id > 0: - flag = True - return flag - else: - flag = False - return flag - except Exception,e: - win32ui.MessageBox("Create Case\n"+str(e),"Mail Reading Error") - return flag + import eml + flag = False + id = -1 + try: + conn = xmlrpclib.ServerProxy(self._uri+ '/xmlrpc/object') + email=eml.generateEML(mail) + message_id = None + session = win32com.client.Dispatch("MAPI.session") + session.Logon('Outlook') + objMessage = session.GetMessage(mail.EntryID, mail.Parent.StoreID) + objFields = objMessage.Fields + strheader = objFields.Item(mapitags.PR_TRANSPORT_MESSAGE_HEADERS) + strheader = ustr(strheader).encode('iso-8859-1') + headers = {} + strheader = strheader.replace("\n ", " ").splitlines() + for line in strheader: + split_here = line.find(":") + headers[line[:split_here]] = line[split_here:] + temp1 = headers.get('Message-ID') + temp2 = headers.get('Message-Id') + if temp1 == None: message_id = temp2 + if temp2 == None: message_id = temp1 + startCut = message_id.find("<") + 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)) + if id > 0: + flag = True + return flag + else: + flag = False + return flag + except Exception,e: + win32ui.MessageBox("Create Case\n"+str(e),"Mail Reading Error") + 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): - 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 + 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): + 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 def CreateContact(self, res=None): - res=eval(str(res)) - partner = res['partner_id'] - state = res['state_id'] - country = res['country_id'] - conn = xmlrpclib.ServerProxy(self._uri+ '/xmlrpc/object') - if not partner.strip() == '': - partner_id = execute( conn, 'execute', self._dbname, int(self._uid), self._pwd, 'res.partner', 'search', [('name','=',ustr(partner))]) - res.update({'partner_id' : partner_id[0]}) - else: - res.pop('partner_id') - if not state == "": - country_id = execute( conn, 'execute', self._dbname, int(self._uid), self._pwd, 'res.country', 'search', [('name','=',ustr(country))]) - res.update({'country_id' : country_id[0]}) - else: - res.pop('country_id') - if not country == "": - state_id = execute( conn, 'execute', self._dbname, int(self._uid), self._pwd, 'res.country.state', 'search', [('name','=',ustr(state))]) - res.update({'state_id' : state_id[0]}) - else: - res.pop('state_id') - id = execute(conn,'execute',self._dbname,int(self._uid),self._pwd,'res.partner.address','create',res) - return id + res=eval(str(res)) + partner = res['partner_id'] + state = res['state_id'] + country = res['country_id'] + conn = xmlrpclib.ServerProxy(self._uri+ '/xmlrpc/object') + if not partner.strip() == '': + partner_id = execute( conn, 'execute', self._dbname, int(self._uid), self._pwd, 'res.partner', 'search', [('name','=',ustr(partner))]) + res.update({'partner_id' : partner_id[0]}) + else: + res.pop('partner_id') + if not state == "": + country_id = execute( conn, 'execute', self._dbname, int(self._uid), self._pwd, 'res.country', 'search', [('name','=',ustr(country))]) + res.update({'country_id' : country_id[0]}) + else: + res.pop('country_id') + if not country == "": + state_id = execute( conn, 'execute', self._dbname, int(self._uid), self._pwd, 'res.country.state', 'search', [('name','=',ustr(state))]) + res.update({'state_id' : state_id[0]}) + else: + res.pop('state_id') + id = execute(conn,'execute',self._dbname,int(self._uid),self._pwd,'res.partner.address','create',res) + return id def CreatePartner(self, res): - res=eval(str(res)) - conn = xmlrpclib.ServerProxy(self._uri+ '/xmlrpc/object') - ids = execute(conn,'execute',self._dbname,int(self._uid),self._pwd,'res.partner','search',[('name','=',res['name'])]) - if ids: - return False - id = execute(conn,'execute',self._dbname,int(self._uid),self._pwd,'res.partner','create',res) - return id + res=eval(str(res)) + conn = xmlrpclib.ServerProxy(self._uri+ '/xmlrpc/object') + ids = execute(conn,'execute',self._dbname,int(self._uid),self._pwd,'res.partner','search',[('name','=',res['name'])]) + if ids: + return False + id = execute(conn,'execute',self._dbname,int(self._uid),self._pwd,'res.partner','create',res) + return id def SearchPartnerDetail(self, search_email_id): - res_vals = [] - conn = xmlrpclib.ServerProxy(self._uri+ '/xmlrpc/object') - address_id = execute(conn, 'execute', self._dbname, int(self._uid), self._pwd, 'res.partner.address', 'search', [('email','ilike',ustr(search_email_id))]) - if not address_id : - return - address = execute(conn, 'execute', self._dbname, int(self._uid), self._pwd, 'res.partner.address','read',address_id[0],['id','partner_id','name','street','street2','city','state_id','country_id','phone','mobile','email','fax','zip']) - for key, vals in address.items(): - res_vals.append([key,vals]) - return res_vals + res_vals = [] + conn = xmlrpclib.ServerProxy(self._uri+ '/xmlrpc/object') + address_id = execute(conn, 'execute', self._dbname, int(self._uid), self._pwd, 'res.partner.address', 'search', [('email','ilike',ustr(search_email_id))]) + if not address_id : + return + address = execute(conn, 'execute', self._dbname, int(self._uid), self._pwd, 'res.partner.address','read',address_id[0],['id','partner_id','name','street','street2','city','state_id','country_id','phone','mobile','email','fax','zip']) + for key, vals in address.items(): + res_vals.append([key,vals]) + return res_vals def WritePartnerValues(self, new_vals): - flag = -1 - new_dict = dict(new_vals) - email=new_dict['email'] - partner = new_dict['partner'] - country_val = new_dict['country'] - state_val = new_dict['state'] - conn = xmlrpclib.ServerProxy(self._uri+ '/xmlrpc/object') - partner_id = execute( conn, 'execute', self._dbname, int(self._uid), self._pwd, 'res.partner', 'search', [('name','=',ustr(partner))]) - country_id = execute( conn, 'execute', self._dbname, int(self._uid), self._pwd, 'res.country', 'search', [('name','=',ustr(country_val))]) - state_id = execute( conn, 'execute', self._dbname, int(self._uid), self._pwd, 'res.country.state', 'search', [('name','=',ustr(state_val))]) - address_id = execute( conn, 'execute', self._dbname, int(self._uid), self._pwd, 'res.partner.address', 'search', [('email','=',ustr(email))]) - if not partner_id or not address_id or not country_id or not state_id: - return flag - address = execute( conn, 'execute', self._dbname, int(self._uid), self._pwd, 'res.partner.address','read',address_id[0],['id','partner_id','state_id','country_id']) - vals_res_address={ - 'partner_id' : partner_id[0], - 'name' : new_dict['name'], - 'street':new_dict['street'], - 'street2' : new_dict['street2'], - 'city' : new_dict['city'], - 'phone' : new_dict['phone'], - 'mobile' : new_dict['mobile'], - 'fax' : new_dict['fax'], - 'zip' : new_dict['zip'], - 'country_id' : country_id[0], - 'state_id' : state_id[0] - } - temp = execute( conn, 'execute', self._dbname, int(self._uid), self._pwd, 'res.partner.address', 'write', address_id, vals_res_address) - if temp: - flag=1 - else: - flag=0 - return flag + flag = -1 + new_dict = dict(new_vals) + email=new_dict['email'] + partner = new_dict['partner'] + country_val = new_dict['country'] + state_val = new_dict['state'] + conn = xmlrpclib.ServerProxy(self._uri+ '/xmlrpc/object') + partner_id = execute( conn, 'execute', self._dbname, int(self._uid), self._pwd, 'res.partner', 'search', [('name','=',ustr(partner))]) + country_id = execute( conn, 'execute', self._dbname, int(self._uid), self._pwd, 'res.country', 'search', [('name','=',ustr(country_val))]) + state_id = execute( conn, 'execute', self._dbname, int(self._uid), self._pwd, 'res.country.state', 'search', [('name','=',ustr(state_val))]) + address_id = execute( conn, 'execute', self._dbname, int(self._uid), self._pwd, 'res.partner.address', 'search', [('email','=',ustr(email))]) + if not partner_id or not address_id or not country_id or not state_id: + return flag + vals_res_address={ + 'partner_id' : partner_id[0], + 'name' : new_dict['name'], + 'street':new_dict['street'], + 'street2' : new_dict['street2'], + 'city' : new_dict['city'], + 'phone' : new_dict['phone'], + 'mobile' : new_dict['mobile'], + 'fax' : new_dict['fax'], + 'zip' : new_dict['zip'], + 'country_id' : country_id[0], + 'state_id' : state_id[0] + } + temp = execute( conn, 'execute', self._dbname, int(self._uid), self._pwd, 'res.partner.address', 'write', address_id, vals_res_address) + if temp: + flag=1 + else: + flag=0 + return flag def GetAllState(self): - state_list = [] - state_ids = [] - conn = xmlrpclib.ServerProxy(self._uri+ '/xmlrpc/object') - state_ids = execute( conn, 'execute', self._dbname, int(self._uid), self._pwd, 'res.country.state', 'search', []) - for state_id in state_ids: - obj = execute( conn, 'execute', self._dbname, int(self._uid), self._pwd, 'res.country.state', 'read', [state_id],['id','name'])[0] - state_list.append((obj['id'], ustr(obj['name']))) - return state_list + state_list = [] + state_ids = [] + conn = xmlrpclib.ServerProxy(self._uri+ '/xmlrpc/object') + state_ids = execute( conn, 'execute', self._dbname, int(self._uid), self._pwd, 'res.country.state', 'search', []) + for state_id in state_ids: + obj = execute( conn, 'execute', self._dbname, int(self._uid), self._pwd, 'res.country.state', 'read', [state_id],['id','name'])[0] + state_list.append((obj['id'], ustr(obj['name']))) + return state_list def GetAllCountry(self): - country_list = [] - country_ids = [] - conn = xmlrpclib.ServerProxy(self._uri+ '/xmlrpc/object') - country_ids = execute( conn, 'execute', self._dbname, int(self._uid), self._pwd, 'res.country', 'search', []) - for country_id in country_ids: - obj = execute( conn, 'execute', self._dbname, int(self._uid), self._pwd, 'res.country','read', [country_id], ['id','name'])[0] - country_list.append((obj['id'], ustr(obj['name']))) - return country_list + country_list = [] + country_ids = [] + conn = xmlrpclib.ServerProxy(self._uri+ '/xmlrpc/object') + country_ids = execute( conn, 'execute', self._dbname, int(self._uid), self._pwd, 'res.country', 'search', []) + for country_id in country_ids: + obj = execute( conn, 'execute', self._dbname, int(self._uid), self._pwd, 'res.country','read', [country_id], ['id','name'])[0] + country_list.append((obj['id'], ustr(obj['name']))) + return country_list def SearchPartner(self, mail_id = ""): - conn = xmlrpclib.ServerProxy(self._uri+ '/xmlrpc/object') - address = execute( conn, 'execute', self._dbname, int(self._uid), self._pwd, 'res.partner.address', 'search', [('email','=',ustr(mail_id))]) - if not address: - return None - else: - add_rec = execute( conn, 'execute', self._dbname, int(self._uid), self._pwd, 'res.partner.address', 'read', address[0]) - partner = add_rec.get('partner_id',False) - if partner: - return partner[0] + conn = xmlrpclib.ServerProxy(self._uri+ '/xmlrpc/object') + address = execute( conn, 'execute', self._dbname, int(self._uid), self._pwd, 'res.partner.address', 'search', [('email','=',ustr(mail_id))]) + if not address: + return None + else: + add_rec = execute( conn, 'execute', self._dbname, int(self._uid), self._pwd, 'res.partner.address', 'read', address[0]) + partner = add_rec.get('partner_id',False) + if partner: + return partner[0] return True def SearchEmailResources(self, message_id): - connector = 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)]) - if not mail_id: - return None - address = execute( conn, 'execute', self._dbname, int(self._uid), self._pwd, 'mailgate.message','read',mail_id[0],['model','res_id']) - for key, vals in address.items(): - res_vals.append([key,vals]) - return res_vals + 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)]) + if not mail_id: + return None + address = execute( conn, 'execute', self._dbname, int(self._uid), self._pwd, 'mailgate.message','read',mail_id[0],['model','res_id']) + for key, vals in address.items(): + res_vals.append([key,vals]) + return res_vals + def GetCountry(self, country_search=''): - conn = xmlrpclib.ServerProxy(self._uri+ '/xmlrpc/object') - ids=[] - obj_list=[] - domain = [] - if not country_search.strip() == '': - domain.append(('name','ilike',ustr(country_search))) - ids = execute(conn,'execute',self._dbname,int(self._uid),self._pwd,'res.country','search',domain) - if ids: - ids.sort() - for id in ids: - object = execute(conn,'execute',self._dbname,int(self._uid),self._pwd,'res.country','read',[id],['id','name'])[0] - obj_list.append((object['id'], ustr(object['name']))) - obj_list.sort(lambda x, y: cmp(x[1],y[1])) - return obj_list + conn = xmlrpclib.ServerProxy(self._uri+ '/xmlrpc/object') + ids=[] + obj_list=[] + domain = [] + if not country_search.strip() == '': + domain.append(('name','ilike',ustr(country_search))) + ids = execute(conn,'execute',self._dbname,int(self._uid),self._pwd,'res.country','search',domain) + if ids: + ids.sort() + for id in ids: + object = execute(conn,'execute',self._dbname,int(self._uid),self._pwd,'res.country','read',[id],['id','name'])[0] + obj_list.append((object['id'], ustr(object['name']))) + obj_list.sort(lambda x, y: cmp(x[1],y[1])) + return obj_list def GetStates(self, state_search='', country=None): - conn = xmlrpclib.ServerProxy(self._uri+ '/xmlrpc/object') - ids = [] - c_id = [] - obj_list = [] - domain = [] - if not state_search.strip() == '': - domain.append(('name','ilike',ustr(state_search))) - if country == None: - ids = execute(conn,'execute',self._dbname,int(self._uid),self._pwd,'res.country.state','search',domain) - if not country == None: - c_id = execute(conn,'execute',self._dbname,int(self._uid),self._pwd,'res.country','search',[('name','=',ustr(country))]) - domain.append(('country_id','=',c_id[0])) - ids = execute(conn,'execute',self._dbname,int(self._uid),self._pwd,'res.country.state','search',domain) - if ids: - ids.sort() - for id in ids: - object = execute(conn,'execute',self._dbname,int(self._uid),self._pwd,'res.country.state','read',[id],['id','name'])[0] - obj_list.append((object['id'], ustr(object['name']))) - obj_list.sort(lambda x, y: cmp(x[1],y[1])) - return obj_list + conn = xmlrpclib.ServerProxy(self._uri+ '/xmlrpc/object') + ids = [] + c_id = [] + obj_list = [] + domain = [] + if not state_search.strip() == '': + domain.append(('name','ilike',ustr(state_search))) + + if country == None: + ids = execute(conn,'execute',self._dbname,int(self._uid),self._pwd,'res.country.state','search',domain) + if not country == None: + c_id = execute(conn,'execute',self._dbname,int(self._uid),self._pwd,'res.country','search',[('name','=',ustr(country))]) + domain.append(('country_id','=',c_id[0])) + ids = execute(conn,'execute',self._dbname,int(self._uid),self._pwd,'res.country.state','search',domain) + if ids: + ids.sort() + for id in ids: + object = execute(conn,'execute',self._dbname,int(self._uid),self._pwd,'res.country.state','read',[id],['id','name'])[0] + obj_list.append((object['id'], ustr(object['name']))) + obj_list.sort(lambda x, y: cmp(x[1],y[1])) + return obj_list def FindCountryForState(self, state_search=''): - conn = xmlrpclib.ServerProxy(self._uri+ '/xmlrpc/object') - ids = execute(conn,'execute',self._dbname,int(self._uid),self._pwd,'res.country.state','search',[('name','=',ustr(state_search))]) - if not ids: - return None - object = execute(conn,'execute',self._dbname,int(self._uid),self._pwd,'res.country.state','read',ids)[0] - country = object['country_id'][1] - return country + conn = xmlrpclib.ServerProxy(self._uri+ '/xmlrpc/object') + ids = execute(conn,'execute',self._dbname,int(self._uid),self._pwd,'res.country.state','search',[('name','=',ustr(state_search))]) + if not ids: + return None + object = execute(conn,'execute',self._dbname,int(self._uid),self._pwd,'res.country.state','read',ids)[0] + country = object['country_id'][1] + return country def CreateEmailAttachment(self, rec, mail): - conn = xmlrpclib.ServerProxy(self._uri+ '/xmlrpc/object') + conn = xmlrpclib.ServerProxy(self._uri+ '/xmlrpc/object') obj = rec[0] obj_id = rec[1] res = {} @@ -514,15 +515,15 @@ class XMLRpcConn(object): ls = ['*', '/', '\\', '<', '>', ':', '?', '"', '|', '\t', '\n',':','~'] fn = (mail.Subject).replace(' ','') for c in ls: - fn = fn.replace(c,'') + 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] + 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' f = open(fn,"w") body = mail.Body.encode("utf-8") @@ -537,4 +538,3 @@ class XMLRpcConn(object): res['res_id'] = obj_id id = execute(conn,'execute',self._dbname,int(self._uid),self._pwd,'ir.attachment','create',res) return id - -- cgit v1.2.3 From 212fc481ef19b87513fff8cac7bcdda6e207c020 Mon Sep 17 00:00:00 2001 From: jam-openerp Date: Mon, 15 Nov 2010 18:43:54 +0530 Subject: [FIX] Output Directory of the Save eml files bzr revid: jam@tinyerp.com-20101115131354-86ts13spcf5kire1 --- .../outlook/plugin/openerp-outlook-plugin/eml.py | 3 +- .../plugin/openerp-outlook-plugin/tiny_xmlrpc.py | 60 +++++++++++----------- 2 files changed, 31 insertions(+), 32 deletions(-) (limited to 'addons/outlook/plugin') diff --git a/addons/outlook/plugin/openerp-outlook-plugin/eml.py b/addons/outlook/plugin/openerp-outlook-plugin/eml.py index 84d5a50df44..4abee63a041 100644 --- a/addons/outlook/plugin/openerp-outlook-plugin/eml.py +++ b/addons/outlook/plugin/openerp-outlook-plugin/eml.py @@ -50,8 +50,7 @@ def generateEML(mail): eml_name= ustr(sub).encode('iso-8859-1')+'-'+str(mail.EntryID)[-9:] ls = ['*', '/', '\\', '<', '>', ':', '?', '"', '|', '\t', '\n'] - #mails_folder_path = os.path.abspath("%temp%\\dialogs\\resources\\mails\\") - mails_folder_path = os.path.abspath("C:\\printing") + mails_folder_path = os.path.abspath("%temp%\\dialogs\\resources\\mails\\") attachments_folder_path = mails_folder_path + "\\attachments\\" if not os.path.exists(attachments_folder_path): os.makedirs(attachments_folder_path) diff --git a/addons/outlook/plugin/openerp-outlook-plugin/tiny_xmlrpc.py b/addons/outlook/plugin/openerp-outlook-plugin/tiny_xmlrpc.py index 199b6518d7f..7ad2bca13b4 100644 --- a/addons/outlook/plugin/openerp-outlook-plugin/tiny_xmlrpc.py +++ b/addons/outlook/plugin/openerp-outlook-plugin/tiny_xmlrpc.py @@ -268,36 +268,36 @@ class XMLRpcConn(object): flag = False id = -1 try: - conn = xmlrpclib.ServerProxy(self._uri+ '/xmlrpc/object') - email=eml.generateEML(mail) - message_id = None - session = win32com.client.Dispatch("MAPI.session") - session.Logon('Outlook') - objMessage = session.GetMessage(mail.EntryID, mail.Parent.StoreID) - objFields = objMessage.Fields - strheader = objFields.Item(mapitags.PR_TRANSPORT_MESSAGE_HEADERS) - strheader = ustr(strheader).encode('iso-8859-1') - headers = {} - strheader = strheader.replace("\n ", " ").splitlines() - for line in strheader: - split_here = line.find(":") - headers[line[:split_here]] = line[split_here:] - temp1 = headers.get('Message-ID') - temp2 = headers.get('Message-Id') - if temp1 == None: message_id = temp2 - if temp2 == None: message_id = temp1 - startCut = message_id.find("<") - 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)) - if id > 0: - flag = True - return flag - else: - flag = False - return flag - except Exception,e: + conn = xmlrpclib.ServerProxy(self._uri+ '/xmlrpc/object') + email=eml.generateEML(mail) + message_id = None + session = win32com.client.Dispatch("MAPI.session") + session.Logon('Outlook') + objMessage = session.GetMessage(mail.EntryID, mail.Parent.StoreID) + objFields = objMessage.Fields + strheader = objFields.Item(mapitags.PR_TRANSPORT_MESSAGE_HEADERS) + strheader = ustr(strheader).encode('iso-8859-1') + headers = {} + strheader = strheader.replace("\n ", " ").splitlines() + for line in strheader: + split_here = line.find(":") + headers[line[:split_here]] = line[split_here:] + temp1 = headers.get('Message-ID') + temp2 = headers.get('Message-Id') + if temp1 == None: message_id = temp2 + if temp2 == None: message_id = temp1 + startCut = message_id.find("<") + 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)) + if id > 0: + flag = True + return flag + else: + flag = False + return flag + except Exception,e: win32ui.MessageBox("Create Case\n"+str(e),"Mail Reading Error") return flag -- cgit v1.2.3 From 802a7eea9f83498f02ba15f4063377c4fc528b81 Mon Sep 17 00:00:00 2001 From: jam-openerp Date: Tue, 16 Nov 2010 15:57:17 +0530 Subject: [IMP] Outlook : Default List Document Repalced bzr revid: jam@tinyerp.com-20101116102717-j5da1wiz9ujciugv --- addons/outlook/plugin/openerp-outlook-plugin/manager.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'addons/outlook/plugin') diff --git a/addons/outlook/plugin/openerp-outlook-plugin/manager.py b/addons/outlook/plugin/openerp-outlook-plugin/manager.py index 783da92bb2a..faab23a1446 100644 --- a/addons/outlook/plugin/openerp-outlook-plugin/manager.py +++ b/addons/outlook/plugin/openerp-outlook-plugin/manager.py @@ -104,10 +104,9 @@ class OpenERPManager: self.application_directory = os.path.dirname(this_filename) self.windows_data_directory = self.LocateDataDirectory() self.data_directory = self.windows_data_directory - self.default_objects = [('Partners','res.partner',''),('Partner Address','res.partner.address',''), \ - ('Account Invoices','account.invoice',''), ('Accounts','account.account',''), \ - ('Projects', 'project.project',''),('Sale Orders','sale.order',''), \ - ('Project Tasks','project.task',''), ('Products', 'product.product', '')] + self.default_objects = [('Partners','res.partner',''),('Account Invoices','account.invoice',''), \ + ('Products', 'product.product',''),('Sale Orders','sale.order',''), \ + ('Leads','crm.lead','')] self.config=self.LoadConfig() -- cgit v1.2.3 From 286b86df9899617b19d1df36aff0a3b2b862c5e9 Mon Sep 17 00:00:00 2001 From: jam-openerp Date: Tue, 16 Nov 2010 16:12:19 +0530 Subject: [Fix] Outlook: fix buildbot warnings bzr revid: jam@tinyerp.com-20101116104219-wvwhkfxeiioh0ggw --- addons/outlook/plugin/openerp-outlook-plugin/addin.py | 13 ++++++------- addons/outlook/plugin/openerp-outlook-plugin/eml.py | 3 --- 2 files changed, 6 insertions(+), 10 deletions(-) (limited to 'addons/outlook/plugin') diff --git a/addons/outlook/plugin/openerp-outlook-plugin/addin.py b/addons/outlook/plugin/openerp-outlook-plugin/addin.py index 130d8b6e19e..b75342e9996 100644 --- a/addons/outlook/plugin/openerp-outlook-plugin/addin.py +++ b/addons/outlook/plugin/openerp-outlook-plugin/addin.py @@ -90,10 +90,10 @@ class ViewPartners: self.outlook = Dispatch("Outlook.Application") self.ex = self.outlook.ActiveExplorer() if self.ex: - is_login = str(data['login']) + is_login = str(self.data['login']) if is_login == 'False': win32ui.MessageBox("Please login to the database first", "OpenERP Connection", win32con.MB_ICONEXCLAMATION) - elif self.ex.Selection.Count == 1 or ex.Selection.Count == 0: + elif self.ex.Selection.Count == 1 or self.ex.Selection.Count == 0: self.mngr = manager.GetManager() self.mngr.ShowManager("IDD_VIEW_PARTNER_DIALOG") elif self.ex.Selection.Count > 1: @@ -117,13 +117,12 @@ class OpenPartner: def OnClick(self, button, cancel): import win32ui - from manager import ustr self.mngr = manager.GetManager() self.data = self.mngr.LoadConfig() self.outlook = Dispatch("Outlook.Application") self.ex = self.outlook.ActiveExplorer() if ex: - is_login = str(data['login']) + is_login = str(self.data['login']) if is_login == 'False': win32ui.MessageBox("Please login to the database first", "OpenERP Connection", win32con.MB_ICONEXCLAMATION) elif self.ex.Selection.Count == 1: @@ -158,11 +157,11 @@ class OpenDocument: self.outlook = Dispatch("Outlook.Application") self.ex = self.outlook.ActiveExplorer() if self.ex: - is_login = str(data['login']) + is_login = str(self.data['login']) if is_login == 'False': win32ui.MessageBox("Please login to the database first", "OpenERP Connection", win32con.MB_ICONEXCLAMATION) - elif self.ex.Selection.Count == 1 or ex.Selection.Count == 0: - self.mngr = manager.GetManager() + elif self.ex.Selection.Count == 1 or self.ex.Selection.Count == 0: + self.mngr = self.manager.GetManager() self.mngr.ShowManager("IDD_OPEN_DOCUEMNT_DIALOG") elif self.ex.Selection.Count > 1: win32ui.MessageBox("Multiple selection not allowed. Please select only one mail at a time.","Open Document",win32con.MB_ICONINFORMATION) diff --git a/addons/outlook/plugin/openerp-outlook-plugin/eml.py b/addons/outlook/plugin/openerp-outlook-plugin/eml.py index 4abee63a041..cca4a26493e 100644 --- a/addons/outlook/plugin/openerp-outlook-plugin/eml.py +++ b/addons/outlook/plugin/openerp-outlook-plugin/eml.py @@ -25,7 +25,6 @@ import sys import chilkat import os from manager import ustr -import win32ui import email cemail = chilkat.CkEmail() dt = chilkat.SYSTEMTIME() @@ -34,7 +33,6 @@ def generateEML(mail): body = mail.Body.encode("utf-8") recipients = mail.Recipients sender_email = mail.SenderEmailAddress - sender_name = mail.SenderEmailAddress attachments=mail.Attachments cemail = chilkat.CkEmail() @@ -69,7 +67,6 @@ def generateEML(mail): att_file = os.path.join(attachments_folder_path, fn) if os.path.exists(att_file): os.remove(att_file) - f1 = att_file attachments[i].SaveAsFile(att_file) contentType = cemail.addFileAttachment(att_file) if (contentType == None ): -- cgit v1.2.3 From 7da2e252244548646ce26d3a8620e812b885cf3f Mon Sep 17 00:00:00 2001 From: jam-openerp Date: Tue, 16 Nov 2010 17:54:00 +0530 Subject: [IMP] Outlook : Archive eml file with object Instead of the textfile excpet object those who have link bzr revid: jam@tinyerp.com-20101116122400-cn7m0bpwi1gjrlkb --- .../openerp-outlook-plugin/dialogs/dialog_map.py | 19 +++++---- .../outlook/plugin/openerp-outlook-plugin/eml.py | 2 +- .../plugin/openerp-outlook-plugin/tiny_xmlrpc.py | 46 +++++++++++----------- 3 files changed, 32 insertions(+), 35 deletions(-) (limited to 'addons/outlook/plugin') diff --git a/addons/outlook/plugin/openerp-outlook-plugin/dialogs/dialog_map.py b/addons/outlook/plugin/openerp-outlook-plugin/dialogs/dialog_map.py index 2dfd0fdba87..a645270eb49 100644 --- a/addons/outlook/plugin/openerp-outlook-plugin/dialogs/dialog_map.py +++ b/addons/outlook/plugin/openerp-outlook-plugin/dialogs/dialog_map.py @@ -272,15 +272,15 @@ class OKButtonProcessor(ButtonProcessor): return setConnAttribs(server, port, self.mngr) if str(NewConn.getitem('_running')) == 'False': - msg = "No server running on host '%s' at port '%d'. Press ignore to still continue with this configuration?"%(server,port) - r=win32ui.MessageBox(msg, "OpenERP Connection", win32con.MB_ABORTRETRYIGNORE | win32con.MB_ICONQUESTION) - if r==3: - resetConnAttribs(self.window) - return - elif r==4: - self.OnClicked(id) - elif r==5: - setConnAttribs(server, port, self.mngr) + msg = "No server running on host '%s' at port '%d'. Press ignore to still continue with this configuration?"%(server,port) + r=win32ui.MessageBox(msg, "OpenERP Connection", win32con.MB_ABORTRETRYIGNORE | win32con.MB_ICONQUESTION) + if r==3: + resetConnAttribs(self.window) + return + elif r==4: + self.OnClicked(id) + elif r==5: + setConnAttribs(server, port, self.mngr) win32gui.EndDialog(self.window.hwnd, id) class DoneButtonProcessor(ButtonProcessor): @@ -661,7 +661,6 @@ def CreateCase(btnProcessor,*args): if not section: win32ui.MessageBox("Documents can not be created.", "Documents Setting", flag_excl) return - hwndList = win32gui.GetDlgItem(btnProcessor.window.hwnd, btnProcessor.other_ids[1]) partner_ids=[] r = GetSelectedItems(hwndList) diff --git a/addons/outlook/plugin/openerp-outlook-plugin/eml.py b/addons/outlook/plugin/openerp-outlook-plugin/eml.py index cca4a26493e..fe455c91117 100644 --- a/addons/outlook/plugin/openerp-outlook-plugin/eml.py +++ b/addons/outlook/plugin/openerp-outlook-plugin/eml.py @@ -90,4 +90,4 @@ def generateEML(mail): if (success == False): print cemail.lastErrorText() sys.exit() - return new_mail \ No newline at end of file + return new_mail, eml_path \ No newline at end of file diff --git a/addons/outlook/plugin/openerp-outlook-plugin/tiny_xmlrpc.py b/addons/outlook/plugin/openerp-outlook-plugin/tiny_xmlrpc.py index 7ad2bca13b4..36646fb1299 100644 --- a/addons/outlook/plugin/openerp-outlook-plugin/tiny_xmlrpc.py +++ b/addons/outlook/plugin/openerp-outlook-plugin/tiny_xmlrpc.py @@ -80,25 +80,25 @@ class XMLRpcConn(object): self.protocol=None def getitem(self, attrib): - v=self.__getattribute__(attrib) - return str(v) + v=self.__getattribute__(attrib) + return str(v) def setitem(self, attrib, value): return self.__setattr__(attrib, value) def GetDBList(self): - conn = xmlrpclib.ServerProxy(self._uri + '/xmlrpc/db') - try: - db_list = execute(conn, 'list') - if db_list == False: - self._running=False - return [] - else: - self._running=True - except: - db_list=-1 - self._running=True - return db_list + conn = xmlrpclib.ServerProxy(self._uri + '/xmlrpc/db') + try: + db_list = execute(conn, 'list') + if db_list == False: + self._running=False + return [] + else: + self._running=True + except: + db_list=-1 + self._running=True + return db_list def login(self,dbname, user, pwd): self._dbname = dbname @@ -195,7 +195,7 @@ class XMLRpcConn(object): } obj_list= ['crm.lead','project.issue','hr.applicant','res.partner'] if rec[0] not in obj_list: - ids = self.CreateEmailAttachment(rec,mail) + self.CreateEmailAttachment(rec,mail) result = {} if attachments: result = self.MakeAttachment([rec], mail) @@ -269,7 +269,7 @@ class XMLRpcConn(object): id = -1 try: conn = xmlrpclib.ServerProxy(self._uri+ '/xmlrpc/object') - email=eml.generateEML(mail) + email, path = eml.generateEML(mail) message_id = None session = win32com.client.Dispatch("MAPI.session") session.Logon('Outlook') @@ -507,6 +507,8 @@ class XMLRpcConn(object): return country def CreateEmailAttachment(self, rec, mail): + import eml + email, path = eml.generateEML(mail) conn = xmlrpclib.ServerProxy(self._uri+ '/xmlrpc/object') obj = rec[0] obj_id = rec[1] @@ -524,16 +526,12 @@ class XMLRpcConn(object): l = 64 - len(fn) f = fn.split('.') fn = f[0][0:l] + '.' + f[-1] - fn = fn[:-4]+'.txt' - f = open(fn,"w") - body = mail.Body.encode("utf-8") - f.writelines(body) - f.close() - f=open(fn,"rb") + fn = fn[:-4]+".eml" + f = open(path) content = "".join(f.readlines()).encode('base64') f.close() - res['name'] = ustr((mail.Subject).replace(' ','')) - res['datas_fname'] = ustr(fn) + res['name'] = fn + res['datas_fname'] = fn res['datas'] = content res['res_id'] = obj_id id = execute(conn,'execute',self._dbname,int(self._uid),self._pwd,'ir.attachment','create',res) -- cgit v1.2.3 From 2b25d4d7a9163887eddbe7e2f47f352c39111f7a Mon Sep 17 00:00:00 2001 From: jam-openerp Date: Thu, 18 Nov 2010 16:52:24 +0530 Subject: [IMP]Outlook : Open Document should also open Mail using refrences-ids bzr revid: jam@tinyerp.com-20101118112224-fn3zg2usfb96lbb3 --- .../outlook/plugin/openerp-outlook-plugin/addin.py | 113 ++++++--------------- .../plugin/openerp-outlook-plugin/tiny_xmlrpc.py | 61 ++++++----- 2 files changed, 68 insertions(+), 106 deletions(-) (limited to 'addons/outlook/plugin') diff --git a/addons/outlook/plugin/openerp-outlook-plugin/addin.py b/addons/outlook/plugin/openerp-outlook-plugin/addin.py index b75342e9996..eec4e5ed6f2 100644 --- a/addons/outlook/plugin/openerp-outlook-plugin/addin.py +++ b/addons/outlook/plugin/openerp-outlook-plugin/addin.py @@ -50,120 +50,71 @@ def GetConn(): d=Dispatch("Python.OpenERP.XMLRpcConn") return d class Configuration: - def Init(self, application): - self.mngr = None - - def Close(self): - self.mngr = None - self.close() - win32ui.MessageBox("Configuration","Configuration") def OnClick(self, button, cancel): import win32ui try: - self.mngr = manager.GetManager() - self.mngr.ShowManager() + mngr = manager.GetManager() + mngr.ShowManager() except Exception,e: win32ui.MessageBox("Fail to Initialize dialog.\n"+str(e),"OpenERP Configuration", win32con.MB_ICONERROR) return cancel # class ViewPartners: - def Init(self, application): - self.mngr = None - self.data = None - self.outlook = None - self.ex= None - - def Close(self): - self.mngr = None - self.data = None - self.outlook = None - self.ex= None - self.close() - win32ui.MessageBox("ViewPartners","ViewPartners") - def OnClick(self, button, cancel): from win32com.client import Dispatch import win32con - self.mngr = manager.GetManager() - self.data = self.mngr.LoadConfig() - self.outlook = Dispatch("Outlook.Application") - self.ex = self.outlook.ActiveExplorer() - if self.ex: - is_login = str(self.data['login']) + mngr = manager.GetManager() + data = mngr.LoadConfig() + outlook = Dispatch("Outlook.Application") + ex = outlook.ActiveExplorer() + if ex: + is_login = str(data['login']) if is_login == 'False': win32ui.MessageBox("Please login to the database first", "OpenERP Connection", win32con.MB_ICONEXCLAMATION) - elif self.ex.Selection.Count == 1 or self.ex.Selection.Count == 0: - self.mngr = manager.GetManager() - self.mngr.ShowManager("IDD_VIEW_PARTNER_DIALOG") - elif self.ex.Selection.Count > 1: + elif ex.Selection.Count == 1 or ex.Selection.Count == 0: + mngr = manager.GetManager() + mngr.ShowManager("IDD_VIEW_PARTNER_DIALOG") + elif ex.Selection.Count > 1: win32ui.MessageBox("Multiple selection not allowed. Please select only one mail at a time.","Open Contact",win32con.MB_ICONINFORMATION) return cancel # class OpenPartner: - def Init(self, application): - self.mngr = None - self.data = None - self.outlook = None - self.ex= None - - def Close(self): - self.mngr = None - self.data = None - self.outlook = None - self.ex= None - self.close() - win32ui.MessageBox("OpenPartner","OpenPartner") - def OnClick(self, button, cancel): import win32ui - self.mngr = manager.GetManager() - self.data = self.mngr.LoadConfig() - self.outlook = Dispatch("Outlook.Application") - self.ex = self.outlook.ActiveExplorer() + mngr = manager.GetManager() + data = mngr.LoadConfig() + outlook = Dispatch("Outlook.Application") + ex = outlook.ActiveExplorer() if ex: - is_login = str(self.data['login']) + is_login = str(data['login']) if is_login == 'False': win32ui.MessageBox("Please login to the database first", "OpenERP Connection", win32con.MB_ICONEXCLAMATION) - elif self.ex.Selection.Count == 1: - self.mngr = manager.GetManager() - self.mngr.ShowManager("IDD_OPEN_PARTNER_DIALOG") - elif self.ex.Selection.Count == 0: + elif ex.Selection.Count == 1: + mngr = manager.GetManager() + mngr.ShowManager("IDD_OPEN_PARTNER_DIALOG") + elif ex.Selection.Count == 0: win32ui.MessageBox("No mail selected to push to OpenERP","Push to OpenERP",win32con.MB_ICONINFORMATION) - elif self.ex.Selection.Count > 1: + elif ex.Selection.Count > 1: win32ui.MessageBox("Multiple selection not allowed. Please select only one mail at a time.","Push to OpenERP",win32con.MB_ICONINFORMATION) return cancel # class OpenDocument: - def Init(self, application): - self.mngr = None - self.data = None - self.outlook = None - self.ex= None - - def Close(self): - self.mngr = None - self.data = None - self.outlook = None - self.ex= None - self.close() - win32ui.MessageBox("OpenDocument","OpenDocument") - def OnClick(self, button, cancel): from win32com.client import Dispatch import win32con - self.mngr = manager.GetManager() - self.data = self.mngr.LoadConfig() - self.outlook = Dispatch("Outlook.Application") - self.ex = self.outlook.ActiveExplorer() - if self.ex: - is_login = str(self.data['login']) + mngr = manager.GetManager() + data = mngr.LoadConfig() + outlook = Dispatch("Outlook.Application") + ex = outlook.ActiveExplorer() + if ex: + is_login = str(data['login']) if is_login == 'False': win32ui.MessageBox("Please login to the database first", "OpenERP Connection", win32con.MB_ICONEXCLAMATION) - elif self.ex.Selection.Count == 1 or self.ex.Selection.Count == 0: - self.mngr = self.manager.GetManager() - self.mngr.ShowManager("IDD_OPEN_DOCUEMNT_DIALOG") - elif self.ex.Selection.Count > 1: + elif ex.Selection.Count == 1 or ex.Selection.Count == 0: + mngr = manager.GetManager() + mngr.ShowManager("IDD_OPEN_DOCUEMNT_DIALOG") + elif ex.Selection.Count > 1: win32ui.MessageBox("Multiple selection not allowed. Please select only one mail at a time.","Open Document",win32con.MB_ICONINFORMATION) return cancel # diff --git a/addons/outlook/plugin/openerp-outlook-plugin/tiny_xmlrpc.py b/addons/outlook/plugin/openerp-outlook-plugin/tiny_xmlrpc.py index 36646fb1299..85abe755bd7 100644 --- a/addons/outlook/plugin/openerp-outlook-plugin/tiny_xmlrpc.py +++ b/addons/outlook/plugin/openerp-outlook-plugin/tiny_xmlrpc.py @@ -133,35 +133,36 @@ class XMLRpcConn(object): break def ArchiveToOpenERP(self, recs, mail): - import win32con + import win32con + import win32ui conn = xmlrpclib.ServerProxy(self._uri + '/xmlrpc/object') flag = False new_msg = ext_msg ="" message_id = referances = None try: - session = win32com.client.Dispatch("MAPI.session") - session.Logon('Outlook') - objMessage = session.GetMessage(mail.EntryID, mail.Parent.StoreID) - objFields = objMessage.Fields - strheader = objFields.Item(mapitags.PR_TRANSPORT_MESSAGE_HEADERS) - strheader = ustr(strheader).encode('iso-8859-1') - headers = {} - strheader = strheader.replace("\n ", " ").splitlines() - for line in strheader: - split_here = line.find(":") - headers[line[:split_here]] = line[split_here:] - temp1 = headers.get('Message-ID') - temp2 = headers.get('Message-Id') - referances = headers.get('References') - if temp1 == None: message_id = temp2 - if temp2 == None: message_id = temp1 - startCut = message_id.find("<") - endCut = message_id.find(">") - message_id = message_id[startCut:endCut+1] - if not referances == None: - startCut = referances.find("<") - endCut = referances.find(">") - referances = referances[startCut:endCut+1] + session = win32com.client.Dispatch("MAPI.session") + session.Logon('Outlook') + objMessage = session.GetMessage(mail.EntryID, mail.Parent.StoreID) + objFields = objMessage.Fields + strheader = objFields.Item(mapitags.PR_TRANSPORT_MESSAGE_HEADERS) + strheader = ustr(strheader).encode('iso-8859-1') + headers = {} + strheader = strheader.replace("\n ", " ").splitlines() + for line in strheader: + split_here = line.find(":") + headers[line[:split_here]] = line[split_here:] + temp1 = headers.get('Message-ID') + temp2 = headers.get('Message-Id') + referances = headers.get('References') + if temp1 == None: message_id = temp2 + if temp2 == None: message_id = temp1 + startCut = message_id.find("<") + endCut = message_id.find(">") + message_id = message_id[startCut:endCut+1] + if not referances == None: + startCut = referances.find("<") + endCut = referances.find(">") + referances = referances[startCut:endCut+1] except Exception,e: win32ui.MessageBox(str(e),"Archive To OpenERP") return @@ -447,11 +448,21 @@ class XMLRpcConn(object): return True def SearchEmailResources(self, message_id): + 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)]) + ref_mail_id = None if not mail_id: - return None + ref_mail_id = execute( conn, 'execute', self._dbname, int(self._uid), self._pwd, 'mailgate.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']) + 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']) for key, vals in address.items(): res_vals.append([key,vals]) -- cgit v1.2.3 From ce3fb87a358f8c98fce0ed60d2bab599259a5aa9 Mon Sep 17 00:00:00 2001 From: Xavier Morel Date: Fri, 26 Nov 2010 13:53:42 +0100 Subject: [IMP] recompress all PNGs found in addons bzr revid: xmo@openerp.com-20101126125342-lfbn1zbwm58nh9b9 --- .../dialogs/resources/openerp_logo.png | Bin 11053 -> 9201 bytes 1 file changed, 0 insertions(+), 0 deletions(-) (limited to 'addons/outlook/plugin') diff --git a/addons/outlook/plugin/openerp-outlook-plugin/dialogs/resources/openerp_logo.png b/addons/outlook/plugin/openerp-outlook-plugin/dialogs/resources/openerp_logo.png index 1b7461953a1..85c15fe1e7c 100644 Binary files a/addons/outlook/plugin/openerp-outlook-plugin/dialogs/resources/openerp_logo.png and b/addons/outlook/plugin/openerp-outlook-plugin/dialogs/resources/openerp_logo.png differ -- cgit v1.2.3