bzr revid: hmo@tinyerp.com-20101111135052-y17ga2cfk3hohblr
This commit is contained in:
Harry (OpenERP)
2010-11-11 19:20:52 +05:30
4 changed files with 61 additions and 87 deletions
+8 -17
View File
@@ -2,31 +2,22 @@ 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
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
How to install openerp-outlook plug-in?
======================================================================================
1.Open your Python installation directory (e.g.: C:\Python26).
2.Create folder named “openerp-outlook-plugin”.
3.Extract your zip file “outlook-plugin.zip” to the folder.
4.Open the folder outlook-plugin.
5.And Run “Register-plugin.bat” file.
6.Run Outlook and Check addin has been registered.
7.Tools->OpenERP Configuration and test your connection.
8.See User Guide for More.
1. Save the executable plug-in file.
2. Close Outlook Application if Running.
3. Run executable plug-in file and the folllow the instruction.
How to uninstall openerp-outlook plug-in?
=====================================================================================
1.Open the folder outlook-plugin.
2.And Run “Unregister-plugin.bat” file.
1. Go to Control Panel Click "Add/Remove Programmes"
2. You will entry, you will find entry named 'OpenERP Outlook Addin 1.0' select it and click Uninstall.
Note : Plug In has been successfully tested with MS Office 2003 and MS Offcie 2007.
Enjoy Archiving your Outlook E-mails to OpenERP.
+6 -11
View File
@@ -32,7 +32,7 @@ class outlook_installer(osv.osv_memory):
def default_get(self, cr, uid, fields, context={}):
data = super(outlook_installer, self).default_get(cr, uid, fields, context)
data['doc_file'] = 'http://doc.openerp.com/book/2/2_6_Comms/2_6_Comms_outlook.html'
file = open(addons.get_module_resource('outlook','plugin','openerp-outlook-plugin.zip'), 'r')
file = open(addons.get_module_resource('outlook','plugin','openerp-outlook-addin.exe'), 'r')
data['plugin_file'] = base64.encodestring(file.read())
return data
@@ -47,7 +47,7 @@ class outlook_installer(osv.osv_memory):
_defaults = {
'outlook' : True,
'name' : 'OpenERP-Outlook-PlugIn.zip',
'name' : 'Openerp-Outlook-Addin v1.exe',
'doc_name' : 'Installation Guide to OpenERP Outlook Plug-in.doc',
'description' : """
* Save the Outlook plug­-in.
@@ -58,15 +58,10 @@ Pre-requirements :
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)".
How to install openerp-outlook plug-in?
1. Extract zip file “openerp-outlook-plugin.zip” .
2. Open the folder openerp-outlook-plugin.
3. Run “Register-plugin.bat” file.
4. Run Outlook and Check addon has been registered.
5. Tools->OpenERP Configuration and test your connection.
6. See User Guide for more information.
7. Keep All extratced files in some safe places
(e.g. python installation Directory "C:\pythonXX\" or Windows installation Directory "C:\Program Files\" ).
1. Save the executable plug-in file.
2. Close Outlook Application if Running.
3. Run executable plug-in file and the folllow the instruction.
Note :
Please refer README file for dependecies external link, openobject-addons/outlook/README.
"""
@@ -31,32 +31,24 @@ import sys
import os
from win32com.client import Dispatch
import win32con
sys.path.append(os.path.abspath(os.path.dirname(__file__))) #outlook
sys.path.append(os.path.abspath(__file__)) #outlook/addin
import manager
from win32com.client import CastTo
import win32ui
from tiny_xmlrpc import XMLRpcConn
import locale
locale.setlocale(locale.LC_NUMERIC, "C")
# Support for COM objects we use.
gencache.EnsureModule('{00062FFF-0000-0000-C000-000000000046}', 0, 9, 0, bForDemand=True) # Outlook 9
gencache.EnsureModule('{2DF8D04C-5BFA-101B-BDE5-00AA0044DE52}', 0, 2, 1, bForDemand=True) # Office 9
# The TLB defiining the interfaces we implement
universal.RegisterInterfaces('{AC0714F2-3D04-11D1-AE7D-00A0C90F26F4}', 0, 1, 0, ["_IDTExtensibility2"])
global NewConn
# Retrieves registered XMLRPC connection
def GetConn():
d=Dispatch("Python.OpenERP.XMLRpcConn")
return d
class Configuration:
def OnClick(self, button, cancel):
try:
@@ -279,7 +271,6 @@ def RegisterXMLConn(klass):
_winreg.SetValueEx(subkey, "FriendlyName", 0, _winreg.REG_SZ, klass._reg_progid_)
if __name__ == '__main__':
import win32com.server.register
NewConn=XMLRpcConn()
win32com.server.register.UseCommandLine(OutlookAddin)
@@ -32,7 +32,6 @@ import win32ui
waittime = 10
wait_count = 0
wait_limit = 12
def execute(connector, method, *args):
global wait_count
res = False
@@ -168,41 +167,42 @@ class XMLRpcConn(object):
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
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
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),
}
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)
attachment_ids = result.get(model, {}).get(res_id, [])
new_msg += """- {0} : {1}\n""".format(object_name,str(rec[2]))
flag = True
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
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
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),
}
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)
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
@@ -497,6 +497,7 @@ class XMLRpcConn(object):
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))])
@@ -505,20 +506,15 @@ class XMLRpcConn(object):
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, email):
def CreateEmailAttachment(self, rec, mail):
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)
obj = rec[0]
obj_id = rec[1]
res={}
res = {}
res['res_model'] = obj
ls = ['*', '/', '\\', '<', '>', ':', '?', '"', '|', '\t', '\n',':','~']
sub = (email.Subject).replace(' ','')
if sub.strip() == '':
sub = 'NO SBUJECT'
fn = sub
fn = (mail.Subject).replace(' ','')
for c in ls:
fn = fn.replace(c,'')
if len(fn) > 64:
@@ -529,14 +525,15 @@ class XMLRpcConn(object):
l = 64 - len(fn)
f = fn.split('.')
fn = f[0][0:l] + '.' + f[-1]
fn = fn+'.txt'
f=open(fn,"w")
f.writelines(ustr(email.Body).encode('iso-8859-1'))
fn = fn[:-4]+'.txt'
f = open(fn,"w")
body = mail.Body.encode("utf-8")
f.writelines(body)
f.close()
f=open(fn,"r")
f=open(fn,"rb")
content = "".join(f.readlines()).encode('base64')
f.close()
res['name'] = ustr(sub)
res['name'] = ustr((mail.Subject).replace(' ',''))
res['datas_fname'] = ustr(fn)
res['datas'] = content
res['res_id'] = obj_id