~openerp-dev/openobject-client/trunk-win_installer_py2.6-rga

« back to all changes in this revision

Viewing changes to bin/modules/gui/window/__init__.py

  • Committer: pinky
  • Date: 2006-12-07 13:41:40 UTC
  • Revision ID: pinky-56e9b555eeb500d42202250a3456cfa2a6dc78c7
New trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
##############################################################################
 
2
#
 
3
# Copyright (c) 2004 TINY SPRL. (http://tiny.be) All Rights Reserved.
 
4
#                    Fabien Pinckaers <fp@tiny.Be>
 
5
#
 
6
# WARNING: This program as such is intended to be used by professional
 
7
# programmers who take the whole responsability of assessing all potential
 
8
# consequences resulting from its eventual inadequacies and bugs
 
9
# End users who are looking for a ready-to-use solution with commercial
 
10
# garantees and support are strongly adviced to contract a Free Software
 
11
# Service Company
 
12
#
 
13
# This program is Free Software; you can redistribute it and/or
 
14
# modify it under the terms of the GNU General Public License
 
15
# as published by the Free Software Foundation; either version 2
 
16
# of the License, or (at your option) any later version.
 
17
#
 
18
# This program is distributed in the hope that it will be useful,
 
19
# but WITHOUT ANY WARRANTY; without even the implied warranty of
 
20
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
21
# GNU General Public License for more details.
 
22
#
 
23
# You should have received a copy of the GNU General Public License
 
24
# along with this program; if not, write to the Free Software
 
25
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 
26
#
 
27
##############################################################################
 
28
 
 
29
import service
 
30
import rpc
 
31
 
 
32
import common
 
33
import form
 
34
import tree
 
35
 
 
36
class window_int(object):
 
37
        def __init__(self, view, datas):
 
38
                self.name = datas.get('name', _('Unknown Window'))
 
39
 
 
40
class window(service.Service):
 
41
        def __init__(self, name='gui.window'):
 
42
                service.Service.__init__(self, name)
 
43
        def create(self, view_id, model, res_id=False, domain=None, view_type='form', window=None, context={}, mode=None):
 
44
                context.update(rpc.session.context)
 
45
                if view_type=='form':
 
46
                        mode = (mode or 'form,tree').split(',')
 
47
                        win = form.form(model, res_id, domain, view_type=mode, view_ids = (view_id and [view_id]) or [], window=window, context=context)
 
48
                        spool = service.LocalService('spool')
 
49
                        spool.publish('gui.window', win, {})
 
50
                elif view_type=='tree':
 
51
                        if view_id:
 
52
                                view_base =  rpc.session.rpc_exec_auth('/object', 'execute', 'ir.ui.view', 'read', [view_id], ['model', 'type'], context)[0]
 
53
                                model = view_base['model']
 
54
                                view = rpc.session.rpc_exec_auth('/object', 'execute', view_base['model'], 'fields_view_get', view_id, view_base['type'],context)
 
55
                        else:
 
56
                                view = rpc.session.rpc_exec_auth('/object', 'execute', model, 'fields_view_get', False, view_type, context)
 
57
 
 
58
                        win = tree.tree(view, model, res_id, domain, context)
 
59
                        spool = service.LocalService('spool')
 
60
                        spool.publish('gui.window', win, {})
 
61
                else:
 
62
                        import logging
 
63
                        log = logging.getLogger('view')
 
64
                        log.error('unknown view type: '+str(view['type']))
 
65
                        del log
 
66
window()