add target new functionality with view_id
[openerp-client.git] / bin / tinyerp-client.py
blobb5fc875619a3df46f9b0e153e715cf39f8d6c62a
1 #!/usr/bin/python
3 ##############################################################################
5 # Copyright (c) 2004-2008 TINY SPRL. (http://tiny.be) All Rights Reserved.
7 # $Id$
9 # WARNING: This program as such is intended to be used by professional
10 # programmers who take the whole responsability of assessing all potential
11 # consequences resulting from its eventual inadequacies and bugs
12 # End users who are looking for a ready-to-use solution with commercial
13 # garantees and support are strongly adviced to contract a Free Software
14 # Service Company
16 # This program is Free Software; you can redistribute it and/or
17 # modify it under the terms of the GNU General Public License
18 # as published by the Free Software Foundation; either version 2
19 # of the License, or (at your option) any later version.
21 # This program is distributed in the hope that it will be useful,
22 # but WITHOUT ANY WARRANTY; without even the implied warranty of
23 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 # GNU General Public License for more details.
26 # You should have received a copy of the GNU General Public License
27 # along with this program; if not, write to the Free Software
28 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
30 ##############################################################################
31 """
32 Tiny ERP - Client
33 Tiny ERP is an ERP+CRM program for small and medium businesses.
35 The whole source code is distributed under the terms of the
36 GNU Public Licence.
38 (c) 2003-TODAY, Fabien Pinckaers - Tiny sprl
39 """
40 import sys, os
41 import release
42 __author__ = release.author
43 __version__ = release.version
45 import __builtin__
46 __builtin__.__dict__['tinyerp_version'] = __version__
48 import logging
49 logging.basicConfig()
51 from distutils.sysconfig import get_python_lib
52 terp_path = os.path.join(get_python_lib(), 'tinyerp-client')
53 sys.path.append(terp_path)
55 if os.name == 'nt':
56 sys.path.insert(0, os.path.join(os.getcwd(), os.path.dirname(sys.argv[0]), 'GTK\\bin'))
57 sys.path.insert(0, os.path.join(os.getcwd(), os.path.dirname(sys.argv[0]), 'GTK\\lib'))
58 os.environ['PATH'] = os.path.join(os.getcwd(), os.path.dirname(sys.argv[0]), 'GTK\\lib') + ";" + os.environ['PATH']
59 os.environ['PATH'] = os.path.join(os.getcwd(), os.path.dirname(sys.argv[0]), 'GTK\\bin') + ";" + os.environ['PATH']
61 import pygtk
62 pygtk.require('2.0')
63 import gtk
64 import gtk.glade
66 import locale, gettext
68 import atk
69 import gtk._gtk
70 import pango
72 if os.name == 'nt':
73 sys.path.insert(0, os.path.join(os.getcwd(), os.path.dirname(sys.argv[0])))
74 os.environ['PATH'] = os.path.join(os.getcwd(), os.path.dirname(sys.argv[0])) + ";" + os.environ['PATH']
76 import translate
77 translate.setlang()
79 import options
81 translate.setlang(options.options['client.lang'])
83 for logger in options.options['logging.logger'].split(','):
84 if len(logger):
85 loglevel = {'DEBUG':logging.DEBUG, 'INFO':logging.INFO, 'WARNING':logging.WARNING, 'ERROR':logging.ERROR, 'CRITICAL':logging.CRITICAL}
86 log = logging.getLogger(logger)
87 log.setLevel(loglevel[options.options['logging.level'].upper()])
88 if options.options['logging.verbose']:
89 logging.getLogger().setLevel(logging.INFO)
90 else:
91 logging.getLogger().setLevel(logging.ERROR)
94 import modules
95 import common
97 items = [('terp-flag', '_Translation', gtk.gdk.CONTROL_MASK, ord('t'), '')]
98 gtk.stock_add (items)
100 factory = gtk.IconFactory ()
101 factory.add_default ()
103 pix_file = os.path.join(os.getcwd(), os.path.dirname(sys.argv[0]), 'icons')
104 if not os.path.isdir(pix_file):
105 pix_file = os.path.join(options.options['path.pixmaps'],'icons')
107 for fname in os.listdir(pix_file):
108 ffname = os.path.join(pix_file,fname)
109 if not os.path.isfile(ffname):
110 continue
111 iname = os.path.splitext(fname)[0]
112 try:
113 pixbuf = gtk.gdk.pixbuf_new_from_file(ffname)
114 except:
115 pixbuf = None
116 continue
117 if pixbuf:
118 icon_set = gtk.IconSet (pixbuf)
119 factory.add('terp-'+iname, icon_set)
121 common.theme_set()
123 try:
124 win = modules.gui.main.terp_main()
125 if not common.terp_survey():
126 if options.options.rcexist:
127 if options.options['tip.autostart']:
128 common.tipoftheday(win.window)
129 else:
130 win.sig_login()
131 gtk.main()
132 except KeyboardInterrupt, e:
133 log = logging.getLogger('common')
134 log.info(_('Closing Tiny ERP, KeyboardInterrupt'))