bugfix with binary field and wizard
[openerp-client.git] / bin / openerp-client.py
blob5cf095eb38b6d9d71eb142fbd1df97411c8a5576
1 #!/usr/bin/python
2 # -*- encoding: utf-8 -*-
4 ##############################################################################
6 # Copyright (c) 2004-2008 TINY SPRL. (http://tiny.be) All Rights Reserved.
8 # $Id$
10 # WARNING: This program as such is intended to be used by professional
11 # programmers who take the whole responsability of assessing all potential
12 # consequences resulting from its eventual inadequacies and bugs
13 # End users who are looking for a ready-to-use solution with commercial
14 # garantees and support are strongly adviced to contract a Free Software
15 # Service Company
17 # This program is Free Software; you can redistribute it and/or
18 # modify it under the terms of the GNU General Public License
19 # as published by the Free Software Foundation; either version 2
20 # of the License, or (at your option) any later version.
22 # This program is distributed in the hope that it will be useful,
23 # but WITHOUT ANY WARRANTY; without even the implied warranty of
24 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 # GNU General Public License for more details.
27 # You should have received a copy of the GNU General Public License
28 # along with this program; if not, write to the Free Software
29 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
31 ##############################################################################
32 """
33 OpenERP - Client
34 OpenERP is an ERP+CRM program for small and medium businesses.
36 The whole source code is distributed under the terms of the
37 GNU Public Licence.
39 (c) 2003-TODAY, Fabien Pinckaers - Tiny sprl
40 """
41 import sys, os
42 import release
43 __author__ = release.author
44 __version__ = release.version
46 import __builtin__
47 __builtin__.__dict__['openerp_version'] = __version__
49 import logging
50 logging.basicConfig()
52 from distutils.sysconfig import get_python_lib
53 terp_path = os.path.join(get_python_lib(), 'openerp-client')
54 sys.path.append(terp_path)
56 if os.name == 'nt':
57 sys.path.insert(0, os.path.join(os.getcwd(), os.path.dirname(sys.argv[0]), 'GTK\\bin'))
58 sys.path.insert(0, os.path.join(os.getcwd(), os.path.dirname(sys.argv[0]), 'GTK\\lib'))
59 os.environ['PATH'] = os.path.join(os.getcwd(), os.path.dirname(sys.argv[0]), 'GTK\\lib') + ";" + os.environ['PATH']
60 os.environ['PATH'] = os.path.join(os.getcwd(), os.path.dirname(sys.argv[0]), 'GTK\\bin') + ";" + os.environ['PATH']
62 import pygtk
63 pygtk.require('2.0')
64 import gtk
65 import gtk.glade
67 import locale, gettext
69 import atk
70 import gtk._gtk
71 import pango
73 if os.name == 'nt':
74 sys.path.insert(0, os.path.join(os.getcwd(), os.path.dirname(sys.argv[0])))
75 os.environ['PATH'] = os.path.join(os.getcwd(), os.path.dirname(sys.argv[0])) + ";" + os.environ['PATH']
77 import translate
78 translate.setlang()
80 import options
82 # On first run, client won't have a language option,
83 # so try with the LANG environ, or fallback to english
84 client_lang = options.options['client.lang']
85 if client_lang is False:
86 client_lang = os.environ.get('LANG', '')
88 translate.setlang(client_lang)
90 for logger in options.options['logging.logger'].split(','):
91 if len(logger):
92 loglevel = {'DEBUG':logging.DEBUG, 'INFO':logging.INFO, 'WARNING':logging.WARNING, 'ERROR':logging.ERROR, 'CRITICAL':logging.CRITICAL}
93 log = logging.getLogger(logger)
94 log.setLevel(loglevel[options.options['logging.level'].upper()])
95 if options.options['logging.verbose']:
96 logging.getLogger().setLevel(logging.INFO)
97 else:
98 logging.getLogger().setLevel(logging.ERROR)
101 import modules
102 import common
104 items = [('terp-flag', '_Translation', gtk.gdk.CONTROL_MASK, ord('t'), '')]
105 gtk.stock_add (items)
107 factory = gtk.IconFactory ()
108 factory.add_default ()
110 pix_file = os.path.join(os.getcwd(), os.path.dirname(sys.argv[0]), 'icons')
111 if not os.path.isdir(pix_file):
112 pix_file = os.path.join(options.options['path.pixmaps'],'icons')
114 for fname in os.listdir(pix_file):
115 ffname = os.path.join(pix_file,fname)
116 if not os.path.isfile(ffname):
117 continue
118 iname = os.path.splitext(fname)[0]
119 try:
120 pixbuf = gtk.gdk.pixbuf_new_from_file(ffname)
121 except:
122 pixbuf = None
123 continue
124 if pixbuf:
125 icon_set = gtk.IconSet (pixbuf)
126 factory.add('terp-'+iname, icon_set)
128 common.theme_set()
130 try:
131 win = modules.gui.main.terp_main()
132 if not common.terp_survey():
133 if options.options.rcexist:
134 win.sig_login()
135 gtk.main()
136 except KeyboardInterrupt, e:
137 log = logging.getLogger('common')
138 log.info(_('Closing OpenERP, KeyboardInterrupt'))
141 # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: