How to use the tryton.rpc.CONTEXT function in tryton

To help you get started, we’ve selected a few tryton examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github tryton / tryton / tryton / gui / window / view_tree / view_tree_sc.py View on Github external
def update(self):
        store = gtk.ListStore(gobject.TYPE_STRING, gobject.TYPE_STRING,
                gobject.TYPE_STRING)
        user =  rpc._USER
        args = ('model', 'ir.ui.view_sc', 'get_sc', user, self.model,
                rpc.CONTEXT)
        try:
            view_sc = rpc.execute(*args)
        except Exception, exception:
            view_sc = common.process_exception(exception, self.window, *args)
            if not view_sc:
                return
        for shortcut in view_sc:
            num = store.append()
            store.set(num, 0, shortcut['res_id'], 1, shortcut['name'],
                    2, shortcut['id'])
        self.tree.set_model(store)
        if self.model == 'ir.ui.menu':
            Main.get_main().shortcut_set(shortcuts=view_sc)
github tryton / tryton / tryton / wizard / main.py View on Github external
Action.exec_report(res['report'], datas, dia or parent,
                            direct_print=direct_print, email_print=email_print,
                            email=email, context=ctx)
                    datas['ids'] = backup_ids
                else:
                    Action.exec_report(res['report'], datas, dia or parent,
                            direct_print=direct_print, email_print=email_print,
                            email=email, context=ctx)
                state = res['state']
            elif res['type'] == 'state':
                state = res['state']
        if dia:
            dia.destroy()
            dia = None
        try:
            rpc.execute('wizard', action, 'delete', wiz_id, rpc.CONTEXT)
            #XXX to remove when company displayed in status bar
            rpc.context_reload()
        except TrytonServerError:
            pass
github tryton / tryton / tryton / gui / window / tree.py View on Github external
try:
            ctx = {}
            ctx.update(self.context)
            ctx.update(rpc.CONTEXT)
            args = ('model', self.model, 'search', self.domain2, 0, None,
                    None, ctx)
            ids = rpc.execute(*args)
        except Exception, exception:
            ids = common.process_exception(exception, self.window, *args)
            if not ids:
                return
        if self.tree_res.toolbar and not CONFIG['client.modepda']:
            for child in self.toolbar.get_children():
                self.toolbar.remove(child)
            ctx = {}
            ctx.update(rpc.CONTEXT)
            try:
                args = ('model', self.view['model'], 'read', ids,
                        ['name', 'icon'], ctx)
                results = rpc.execute(*args)
            except Exception, exception:
                results = common.process_exception(exception, self.window, *args)
                if not results:
                    return
            results.sort(lambda x, y: cmp(ids.index(x['id']),
                ids.index(y['id'])))
            radiotb = None
            for res in results:
                common.ICONFACTORY.register_icon(res['icon'])
                radiotb = gtk.RadioToolButton(radiotb, res['icon'])
                radiotb.set_label(res['name'])
                radiotb.show_all()
github tryton / tryton / tryton / gui / window / view_form / widget_search / selection.py View on Github external
domain = []
            else:
                domain = PYSONDecoder(rpc.CONTEXT).decode(self.attrs['domain'])
            try:
                result = rpc.execute('model', self.attrs['relation'],
                        'search_read', domain, 0, None, None,
                        ['rec_name'], rpc.CONTEXT)
                selection = [(x['id'], x['rec_name']) for x in result]
            except TrytonServerError, exception:
                common.process_exception(exception)
                selection = []
        else:
            if not isinstance(selection, (list, tuple)):
                try:
                    selection = rpc.execute('model',
                            self.attrs['model'], selection, rpc.CONTEXT)
                except TrytonServerError, exception:
                    common.process_exception(exception)
                    selection = []
        selection.sort(key=operator.itemgetter(1))
        self.attrs['selection'] = selection
        self.set_popdown(selection)
        self.widget.pack_start(self.entry, True, True)
        self.widget.show_all()