示例#1
0
 def do_single_action(self, action, access):
     if action == 'new':
         if access['create']:
             self.new()
     elif action == 'delete':
         if access['delete']:
             self.remove(delete=not self.parent,
                         force_remove=not self.parent)
     elif action == 'remove':
         if access['write'] and access['read'] and self.parent:
             self.remove(remove=True)
     elif action == 'copy':
         if access['create']:
             self.copy()
     elif action == 'next':
         self.display_next()
     elif action == 'previous':
         self.display_prev()
     elif action == 'close':
         from tryton.gui import Main
         Main.get_main().sig_win_close()
     elif action.startswith('switch'):
         _, view_type = action.split(None, 1)
         self.switch_view(view_type=view_type)
     elif action == 'reload':
         if (self.current_view.view_type in ['tree', 'graph', 'calendar']
                 and not self.parent):
             self.search_filter()
     elif action == 'reload menu':
         from tryton.gui import Main
         RPCContextReload(Main.get_main().sig_win_menu)
     elif action == 'reload context':
         RPCContextReload()
示例#2
0
 def client_action(self, action):
     access = MODELACCESS[self.model_name]
     if action == 'new':
         if access['create']:
             self.new()
     elif action == 'delete':
         if access['delete']:
             self.remove(delete=not self.parent,
                 force_remove=not self.parent)
     elif action == 'remove':
         if access['write'] and access['read'] and self.parent:
             self.remove(remove=True)
     elif action == 'copy':
         if access['create']:
             self.copy()
     elif action == 'next':
         self.display_next()
     elif action == 'previous':
         self.display_prev()
     elif action == 'close':
         from tryton.gui import Main
         Main().sig_win_close()
     elif action.startswith('switch'):
         self.switch_view(*action.split(None, 2)[1:])
     elif action == 'reload':
         if (self.current_view.view_type in ['tree', 'graph', 'calendar']
                 and not self.parent):
             self.search_filter()
     elif action == 'reload menu':
         from tryton.gui import Main
         RPCContextReload(Main().sig_win_menu)
     elif action == 'reload context':
         RPCContextReload()
示例#3
0
 def destroy(self, action=None):
     if self.toolbar_box.get_children():
         toolbar = self.toolbar_box.get_children()[0]
         self.toolbar_box.remove(toolbar)
     super(WizardForm, self).destroy(action=action)
     if action == 'reload menu':
         RPCContextReload(Main().sig_win_menu)
     elif action == 'reload context':
         RPCContextReload()
示例#4
0
    def get_preferences(self):
        RPCContextReload()
        try:
            prefs = RPCExecute('model', 'res.user', 'get_preferences', False)
        except RPCException:
            prefs = {}

        threads = []
        for target in (
                common.IconFactory.load_icons,
                common.MODELACCESS.load_models,
                common.MODELHISTORY.load_history,
                common.VIEW_SEARCH.load_searches,
                ):
            t = threading.Thread(target=target)
            threads.append(t)
            t.start()
        for t in threads:
            t.join()
        if prefs and 'language_direction' in prefs:
            translate.set_language_direction(prefs['language_direction'])
            CONFIG['client.language_direction'] = \
                prefs['language_direction']
        self.sig_win_menu(prefs=prefs)
        for action_id in prefs.get('actions', []):
            Action.execute(action_id, {})
        self.set_title(prefs.get('status_bar', ''))
        if prefs and 'language' in prefs:
            translate.setlang(prefs['language'], prefs.get('locale'))
            if CONFIG['client.lang'] != prefs['language']:
                self.favorite_unset()
            CONFIG['client.lang'] = prefs['language']
        # Set placeholder after language is set to get correct translation
        self.global_search_entry.set_placeholder_text(_("Action"))
        CONFIG.save()
示例#5
0
    def get_preferences(self, date=''):
        def _set_preferences(prefs):
            try:
                prefs = prefs()
            except RPCException:
                prefs = {}
            threads = []
            for target in (
                    common.IconFactory.load_icons,
                    common.MODELACCESS.load_models,
                    common.MODELHISTORY.load_history,
                    common.VIEW_SEARCH.load_searches,
            ):
                t = threading.Thread(target=target)
                threads.append(t)
                t.start()
            for t in threads:
                t.join()
            if prefs and 'language_direction' in prefs:
                translate.set_language_direction(prefs['language_direction'])
                CONFIG['client.language_direction'] = \
                    prefs['language_direction']
            self.sig_win_menu(prefs=prefs)
            for action_id in prefs.get('actions', []):
                Action.execute(action_id, {})
            connexion_date = date.strftime('%d/%m/%Y') if date else ''
            self.set_title(prefs.get('status_bar', ''), connexion_date)
            # AKE: change bg color based on preferences
            color_bg = prefs.get('color_bg', None) or os.environ.get(
                'TRYTON_CLIENT_BG_COLOR', None)
            if color_bg:
                self.window.modify_bg(gtk.STATE_NORMAL,
                                      gtk.gdk.color_parse(color_bg))
            if prefs and 'language' in prefs:
                translate.setlang(prefs['language'], prefs.get('locale'))
                if CONFIG['client.lang'] != prefs['language']:
                    self.favorite_unset()
                CONFIG['client.lang'] = prefs['language']
            # Set placeholder after language is set to get correct translation
            self.global_search_entry.set_placeholder_text(_("Action"))
            CONFIG.save()

        def _get_preferences():
            RPCExecute('model',
                       'res.user',
                       'get_preferences',
                       False,
                       callback=_set_preferences)

        RPCContextReload(_get_preferences)
示例#6
0
文件: wizard.py 项目: xyzlat/tryton
 def destroy(self, action=None):
     super(WizardForm, self).destroy(action=action)
     if action == 'reload menu':
         RPCContextReload(Main().sig_win_menu)
     elif action == 'reload context':
         RPCContextReload()