3
import win32api, win32con, win32gui
5
import win32com.client.gencache
11
# Maintain compatibility with Python 2.2
15
filesystem_encoding = sys.getfilesystemencoding()
16
except AttributeError:
17
filesystem_encoding = "mbcs"
19
# Work out our "application directory", which is
20
# the directory of our main .py/.dll/.exe file we
22
if hasattr(sys, "frozen"):
23
assert sys.frozen == "dll", "outlook only supports inproc servers"
24
this_filename = win32api.GetModuleFileName(sys.frozendllhandle)
27
this_filename = os.path.abspath(__file__)
28
except NameError: # no __file__ - means Py2.2 and __name__=='__main__'
29
this_filename = os.path.abspath(sys.argv[0])
30
# See if we can use the new bsddb module. (The old one is unreliable
31
# on Windows, so we don't use that)
33
import bsddb3 as bsddb
34
# bsddb3 is definitely not broken
37
# Not using the 3rd party bsddb3, so try the one in the std library
40
use_db = hasattr(bsddb, "db") # This name is not in the old one.
42
# No DB library at all!
43
assert not hasattr(sys, "frozen"), \
44
"Don't build binary versions without bsddb!"
47
# Our main "bayes manager"
50
def __init__(self, config_base="default", outlook=None, verbose=0):
51
self.outlook = outlook
52
self.dialog_parser = None
53
self.application_directory = os.path.dirname(this_filename)
54
self.windows_data_directory = self.LocateDataDirectory()
55
self.data_directory = self.windows_data_directory
56
self.default_objects = [('Partners','res.partner',''),('Partner Address','res.partner.address',''), \
57
('Account Invoices','account.invoice',''), ('Accounts','account.account',''), \
58
('Projects', 'project.project',''),('Sale Orders','sale.order',''), \
59
('CRM Cases', 'crm.case',''),('Project Tasks','project.task',''), ('Products', 'product.product', '')]
60
self.config=self.LoadConfig()
62
def WorkerThreadStarting(self):
63
pythoncom.CoInitialize()
65
def WorkerThreadEnding(self):
66
pythoncom.CoUninitialize()
68
def LocateDataDirectory(self):
69
# Locate the best directory for our data files.
70
from win32com.shell import shell, shellcon
72
appdata = shell.SHGetFolderPath(0,shellcon.CSIDL_APPDATA,0,0)
73
path = os.path.join(appdata, "OpenERP-Plugin")
74
if not os.path.isdir(path):
77
except pythoncom.com_error:
78
# Function doesn't exist on early win95,
79
# and it may just fail anyway!
80
return self.application_directory
81
except EnvironmentError:
82
# Can't make the directory.
83
return self.application_directory
85
def ShowManager(self, id="IDD_MANAGER"):
87
dialogs.ShowDialog(0, self, self.config, id)
90
path = os.path.join(self.data_directory, 'tiny.ini')
91
data = {'server' : 'localhost', 'port' : '8069', 'database' : '', 'objects' : self.default_objects, 'uname':'admin', 'pwd':'a', 'login':False}
92
if os.path.exists(path):
103
def SaveConfig(self):
104
path = os.path.join(self.data_directory, 'tiny.ini')
106
fp.write(str(self.config))
110
def GetManager(outlook = None):
114
outlook = win32com.client.Dispatch("Outlook.Application")
115
_mgr = OpenERPManager(outlook=outlook)
118
def ShowManager(mgr):
121
def main(verbose_level = 1):
127
print "Usage: manager [-v ...]"
130
if __name__=='__main__':
133
opts, args = getopt.getopt(sys.argv[1:], "v")
136
for opt, val in opts:
141
sys.exit(main(verbose))