[MERGE] Merge Improvement of outlook plugin

bzr revid: sbh@tinyerp.com-20101116092513-3ponwr28aosrux5m
This commit is contained in:
sbh (Open ERP)
2010-11-16 14:55:13 +05:30
6 changed files with 139 additions and 85 deletions
+5 -2
View File
@@ -3,8 +3,11 @@ OpenERP Outlook PLUG-IN Installation Guide
Pre requirements :
======================================================================================
1.Python 2.6+ . python can be downloaded from http://www.python.org/download/releases/ .
2.Python for Windows extensions - PyWin32 this module for python must be installed for appropriate version of the Python. It can be downloaded from http://sourceforge.net/projects/pywin32/files/ or http://starship.python.net/crew/mhammond/win32/
3.If you are using MS Outlook 2007 than you are required to install "Microsoft Exchange Server MAPI Client and Collaboration Data Objects 1.2.1 (CDO 1.21)". It can be downloaded from http://www.microsoft.com/downloads/en/details.aspx?FamilyID=e17e7f31-079a-43a9-bff2-0a110307611e&displaylang=en
2.Python for Windows extensions - PyWin32 this module for python must be installed for appropriate version of the Python. It can be downloaded from
http://sourceforge.net/projects/pywin32/ or
http://starship.python.net/crew/mhammond/win32/
3.If you are using MS Outlook 2007 than you are required to install "Microsoft Exchange Server MAPI Client and Collaboration Data Objects 1.2.1 (CDO 1.21)". It can be downloaded from
http://www.microsoft.com/downloads/en/details.aspx?familyid=2714320d-c997-4de1-986f-24f081725d36&displaylang=en
How to install openerp-outlook plug-in?
======================================================================================
@@ -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
#
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("OpenPartner","OpenPartner")
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()
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 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:
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
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 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
@@ -1412,7 +1412,6 @@ def SerachOpenDocuemnt(txtProcessor,*args):
txtProcessor.init_done=True
return
linktodoc = ""
message_id = None
try:
session = win32com.client.Dispatch("MAPI.session")
File diff suppressed because one or more lines are too long
@@ -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)
@@ -27,7 +27,7 @@ import time
from manager import ustr
from win32com.mapi import mapitags
import pythoncom
import win32com
import win32com
import win32ui
waittime = 10
wait_count = 0
@@ -200,6 +200,7 @@ class XMLRpcConn(object):
if attachments:
result = self.MakeAttachment([rec], mail)
attachment_ids = result.get(model, {}).get(res_id, [])
execute(conn,'execute',self._dbname,int(self._uid),self._pwd,'email.server.tools','history',model, res_id, msg, attachment_ids)
new_msg += """- {0} : {1}\n""".format(object_name,str(rec[2]))
flag = True
@@ -267,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