コード例 #1
0
ファイル: many2many.py プロジェクト: sallecta/openerp-client
 def row_activate(self, screen):
     gui_window = service.LocalService('gui.window')
     domain = self._view.modelfield.domain_get(self._view.model)
     dia = dialog(screen.name, id=screen.id_get(), attrs=self.attrs, domain=domain, window=screen.window,context=screen.context,target=False, view_type=['form'])
     if dia.dia.get_has_separator():
         dia.dia.set_has_separator(False)
     ok, value = dia.run()
     if ok:
         screen.current_model.validate_set()
         screen.current_view.set_value()
     dia.destroy()
コード例 #2
0
    def _exec_action(self, action, datas, context={}):
        if isinstance(action, bool) or 'type' not in action:
            return
        # Updating the context : Adding the context of action in order to use it on Views called from buttons
        if datas.get('id',False):
            context.update( {'active_id': datas.get('id',False), 'active_ids': datas.get('ids',[]), 'active_model': datas.get('model',False)})
        context.update(tools.expr_eval(action.get('context','{}'), context.copy()))
        if action['type'] in ['ir.actions.act_window', 'ir.actions.submenu']:
            for key in ('res_id', 'res_model', 'view_type', 'view_mode',
                    'limit', 'auto_refresh', 'search_view', 'auto_search', 'search_view_id'):
                datas[key] = action.get(key, datas.get(key, None))

            datas['auto_search'] = action.get('auto_search', True)
            if not datas['search_view'] and datas['search_view_id']:
                 datas['search_view'] = str(rpc.session.rpc_exec_auth('/object', 'execute', datas['res_model'], 'fields_view_get', isinstance(datas['search_view_id'], (tuple, list)) and datas['search_view_id'][0] or datas['search_view_id'], 'search', context))

            if datas['limit'] is None or datas['limit'] == 0:
                datas['limit'] = 100

            view_ids=False
            if action.get('views', []):
                if isinstance(action['views'],list):
                    view_ids=[x[0] for x in action['views']]
                    datas['view_mode']=",".join([x[1] for x in action['views']])
                else:
                    if action.get('view_id', False):
                        view_ids=[action['view_id'][0]]
            elif action.get('view_id', False):
                view_ids=[action['view_id'][0]]

            if not action.get('domain', False):
                action['domain']='[]'
            domain_ctx = context.copy()
            domain_ctx['time'] = time
            domain_ctx['datetime'] = datetime
            domain = tools.expr_eval(action['domain'], domain_ctx)
            help = {}
            if action.get('display_menu_tip', False):
                msg = action.get('help', False)
                title = action.get('name', False)
                if msg and len(msg):
                    help['msg'] =  msg
                    help['title'] = title or ''
            if datas.get('domain', False):
                domain.append(datas['domain'])
            if action.get('target', False)=='new':
                dia = dialog(datas['res_model'], id=datas.get('res_id',None),
                             window=datas.get('window',None), domain=domain,
                             context=context, view_ids=view_ids,target=True,
                             view_type=datas.get('view_mode', 'tree').split(','), help=help)
                if dia.dia.get_has_separator():
                    dia.dia.set_has_separator(False)
                dia.run()
                dia.destroy()
            else:
                obj = service.LocalService('gui.window')
                obj.create(view_ids, datas['res_model'], datas['res_id'], domain,
                        action['view_type'], datas.get('window',None), context,
                        datas['view_mode'], name=action.get('name', False), help=help,
                        limit=datas['limit'], auto_refresh=datas['auto_refresh'], auto_search = datas['auto_search'], search_view = datas['search_view'])

        elif action['type']=='ir.actions.server':
            res = rpc.session.rpc_exec_auth('/object', 'execute', 'ir.actions.server', 'run', [action['id']], context)
            if res:
                if not isinstance(res, list):
                    res = [res]
                for r in res:
                    self._exec_action(r, datas, context)

        elif action['type']=='ir.actions.wizard':
            win=None
            if 'window' in datas:
                win=datas['window']
                del datas['window']
            wizard.execute(action['wiz_name'], datas, parent=win, context=context)

        elif action['type']=='ir.actions.report.custom':
            if 'window' in datas:
                win=datas['window']
                del datas['window']
            datas['report_id'] = action['report_id']
            self.exec_report('custom', datas, context)

        elif action['type']=='ir.actions.report.xml':
            if 'window' in datas:
                win=datas['window']
                del datas['window']
            if not datas:
                datas = action.get('datas',[])
            self.exec_report(action['report_name'], datas, context)

        elif action['type']=='ir.actions.act_url':
            tools.launch_browser(action.get('url',''))
コード例 #3
0
    def _exec_action(self, action, datas, context={}):
        if isinstance(action, bool) or 'type' not in action:
            return
        # Updating the context : Adding the context of action in order to use it on Views called from buttons
        if datas.get('id',False):
            context.update( {'active_id': datas.get('id',False), 'active_ids': datas.get('ids',[]), 'active_model': datas.get('model',False)})
        context.update(tools.expr_eval(action.get('context','{}'), context.copy()))
        if action['type'] in ['ir.actions.act_window', 'ir.actions.submenu']:
            for key in ('res_id', 'res_model', 'view_type', 'view_mode',
                    'limit', 'auto_refresh', 'search_view', 'auto_search', 'search_view_id'):
                datas[key] = action.get(key, datas.get(key, None))

            datas['auto_search'] = action.get('auto_search', True)
            if not datas['search_view'] and datas['search_view_id']:
                 datas['search_view'] = str(rpc.session.rpc_exec_auth('/object', 'execute', datas['res_model'], 'fields_view_get', isinstance(datas['search_view_id'], (tuple, list)) and datas['search_view_id'][0] or datas['search_view_id'], 'search', context))

            if datas['limit'] is None or datas['limit'] == 0:
                datas['limit'] = 100

            view_ids=False
            if action.get('views', []):
                if isinstance(action['views'],list):
                    view_ids=[x[0] for x in action['views']]
                    datas['view_mode']=",".join([x[1] for x in action['views']])
                else:
                    if action.get('view_id', False):
                        view_ids=[action['view_id'][0]]
            elif action.get('view_id', False):
                view_ids=[action['view_id'][0]]

            if not action.get('domain', False):
                action['domain']='[]'
            domain_ctx = context.copy()
            domain_ctx['time'] = time
            domain_ctx['datetime'] = datetime
            domain = tools.expr_eval(action['domain'], domain_ctx)
            help = {}
            if action.get('display_menu_tip', False):
                msg = action.get('help', False)
                title = action.get('name', False)
                if msg and len(msg):
                    help['msg'] =  msg
                    help['title'] = title or ''
            if datas.get('domain', False):
                domain.append(datas['domain'])
            if action.get('target', False)=='new':
                dia = dialog(datas['res_model'], id=datas.get('res_id',None),
                             window=datas.get('window',None), domain=domain,
                             context=context, view_ids=view_ids,target=True,
                             view_type=datas.get('view_mode', 'tree').split(','), help=help)
                if dia.dia.get_has_separator():
                    dia.dia.set_has_separator(False)
                dia.run()
                dia.destroy()
            else:
                obj = service.LocalService('gui.window')
                obj.create(view_ids, datas['res_model'], datas['res_id'], domain,
                        action['view_type'], datas.get('window',None), context,
                        datas['view_mode'], name=action.get('name', False), help=help,
                        limit=datas['limit'], auto_refresh=datas['auto_refresh'], auto_search = datas['auto_search'], search_view = datas['search_view'])

        elif action['type']=='ir.actions.server':
            res = rpc.session.rpc_exec_auth('/object', 'execute', 'ir.actions.server', 'run', [action['id']], context)
            if res:
                if not isinstance(res, list):
                    res = [res]
                for r in res:
                    self._exec_action(r, datas, context)

        elif action['type']=='ir.actions.wizard':
            win=None
            if 'window' in datas:
                win=datas['window']
                del datas['window']
            wizard.execute(action['wiz_name'], datas, parent=win, context=context)

        elif action['type']=='ir.actions.report.custom':
            if 'window' in datas:
                win=datas['window']
                del datas['window']
            datas['report_id'] = action['report_id']
            self.exec_report('custom', datas, context)

        elif action['type']=='ir.actions.report.xml':
            if 'window' in datas:
                win=datas['window']
                del datas['window']
            if not datas:
                datas = action.get('datas',[])
            self.exec_report(action['report_name'], datas, context)

        elif action['type']=='ir.actions.act_url':
            tools.launch_browser(action.get('url',''))
コード例 #4
0
    def _exec_action(self, action, datas, context={}):
        if isinstance(action, bool) or 'type' not in action:
            return
        # Update context, adding the dynamic context of the action
        context.update(
            tools.expr_eval(action.get('context', '{}'), context.copy()))
        if action['type'] == 'ir.actions.act_window':
            for key in ('res_id', 'res_model', 'view_type', 'view_mode',
                        'limit', 'auto_refresh'):
                datas[key] = action.get(key, datas.get(key, None))

            if datas['limit'] is None or datas['limit'] == 0:
                datas['limit'] = 80

            view_ids = False
            if action.get('views', []):
                if isinstance(action['views'], list):
                    view_ids = [x[0] for x in action['views']]
                    datas['view_mode'] = ",".join(
                        [x[1] for x in action['views']])
                else:
                    #                    view_ids=[(action['view_type']=='tree') and 1 or False,(action['view_type']=='form') and 1 or False]
                    if action.get('view_id', False):
                        view_ids = [action['view_id'][0]]
            elif action.get('view_id', False):
                view_ids = [action['view_id'][0]]

            if not action.get('domain', False):
                action['domain'] = '[]'
            ctx = context.copy()
            ctx.update({
                'active_id': datas.get('id', False),
                'active_ids': datas.get('ids', [])
            })
            ctx.update(tools.expr_eval(action.get('context', '{}'),
                                       ctx.copy()))

            a = ctx.copy()
            a['time'] = time
            a['datetime'] = datetime
            domain = tools.expr_eval(action['domain'], a)

            if datas.get('domain', False):
                domain.append(datas['domain'])
            if action.get('target', False) == 'new':
                dia = dialog(datas['res_model'],
                             id=datas.get('res_id', None),
                             window=datas.get('window', None),
                             domain=domain,
                             context=ctx,
                             view_ids=view_ids,
                             target=True,
                             view_type=datas.get('view_mode',
                                                 'tree').split(','))
                if dia.dia.get_has_separator():
                    dia.dia.set_has_separator(False)
                dia.run()
                dia.destroy()
            else:
                obj = service.LocalService('gui.window')
                obj.create(view_ids,
                           datas['res_model'],
                           datas['res_id'],
                           domain,
                           action['view_type'],
                           datas.get('window', None),
                           ctx,
                           datas['view_mode'],
                           name=action.get('name', False),
                           limit=datas['limit'],
                           auto_refresh=datas['auto_refresh'])

        elif action['type'] == 'ir.actions.server':
            ctx = context.copy()
            ctx.update({
                'active_id': datas.get('id', False),
                'active_ids': datas.get('ids', [])
            })
            res = rpc.session.rpc_exec_auth('/object', 'execute',
                                            'ir.actions.server', 'run',
                                            [action['id']], ctx)
            if res:
                if not isinstance(res, list):
                    res = [res]
                for r in res:
                    self._exec_action(r, datas, context)

        elif action['type'] == 'ir.actions.wizard':
            win = None
            if 'window' in datas:
                win = datas['window']
                del datas['window']
            wizard.execute(action['wiz_name'],
                           datas,
                           parent=win,
                           context=context)

        elif action['type'] == 'ir.actions.report.custom':
            if 'window' in datas:
                win = datas['window']
                del datas['window']
            datas.update(action.get('datas', {}))
            datas['report_id'] = action['report_id']
            self.exec_report('custom', datas, context)

        elif action['type'] == 'ir.actions.report.xml':
            if 'window' in datas:
                win = datas['window']
                del datas['window']
            datas.update(action.get('datas', {}))
            self.exec_report(action['report_name'], datas, context)

        elif action['type'] == 'ir.actions.act_url':
            tools.launch_browser(action.get('url', ''))
コード例 #5
0
ファイル: main.py プロジェクト: gisce/erpclient
    def _exec_action(self, action, datas, context={}):
        if isinstance(action, bool) or 'type' not in action:
            return
        # Update context, adding the dynamic context of the action
        context.update(tools.expr_eval(action.get('context','{}'), context.copy()))
        if action['type']=='ir.actions.act_window':
            for key in ('res_id', 'res_model', 'view_type', 'view_mode',
                    'limit', 'auto_refresh'):
                datas[key] = action.get(key, datas.get(key, None))

            if datas['limit'] is None or datas['limit'] == 0:
                datas['limit'] = 80

            view_ids=False
            if action.get('views', []):
                if isinstance(action['views'],list):
                    view_ids=[x[0] for x in action['views']]
                    datas['view_mode']=",".join([x[1] for x in action['views']])
                else:
#                    view_ids=[(action['view_type']=='tree') and 1 or False,(action['view_type']=='form') and 1 or False]
                    if action.get('view_id', False):
                        view_ids=[action['view_id'][0]]
            elif action.get('view_id', False):
                view_ids=[action['view_id'][0]]

            if not action.get('domain', False):
                action['domain']='[]'
            ctx = context.copy()
            ctx.update( {'active_id': datas.get('id',False), 'active_ids': datas.get('ids',[])} )
            ctx.update(tools.expr_eval(action.get('context','{}'), ctx.copy()))

            a = ctx.copy()
            a['time'] = time
            a['datetime'] = datetime
            domain = tools.expr_eval(action['domain'], a)

            if datas.get('domain', False):
                domain.append(datas['domain'])
            if action.get('target', False)=='new':
                dia = dialog(datas['res_model'], id=datas.get('res_id',None), window=datas.get('window',None), domain=domain, context=ctx, view_ids=view_ids,target=True, view_type=datas.get('view_mode', 'tree').split(','))
                if dia.dia.get_has_separator():
                    dia.dia.set_has_separator(False)
                dia.run()
                dia.destroy()
            else:
                obj = service.LocalService('gui.window')
                obj.create(view_ids, datas['res_model'], datas['res_id'], domain,
                        action['view_type'], datas.get('window',None), ctx,
                        datas['view_mode'], name=action.get('name', False),
                        limit=datas['limit'], auto_refresh=datas['auto_refresh'])

        elif action['type']=='ir.actions.server':
            ctx = context.copy()
            ctx.update({'active_id': datas.get('id',False), 'active_ids': datas.get('ids',[])})
            res = rpc.session.rpc_exec_auth('/object', 'execute', 'ir.actions.server', 'run', [action['id']], ctx)
            if res:
                if not isinstance(res, list):
                    res = [res]
                for r in res:
                    self._exec_action(r, datas, context)

        elif action['type']=='ir.actions.wizard':
            win=None
            if 'window' in datas:
                win=datas['window']
                del datas['window']
            wizard.execute(action['wiz_name'], datas, parent=win, context=context)

        elif action['type']=='ir.actions.report.custom':
            if 'window' in datas:
                win=datas['window']
                del datas['window']
            datas.update(action.get('datas',{}))
            datas['report_id'] = action['report_id']
            self.exec_report('custom', datas, context)

        elif action['type']=='ir.actions.report.xml':
            if 'window' in datas:
                win=datas['window']
                del datas['window']
            datas.update(action.get('datas',{}))
            self.exec_report(action['report_name'], datas, context)

        elif action['type']=='ir.actions.act_url':
            tools.launch_browser(action.get('url',''))