def button_action(self, **kw): params, data = TinyDict.split(kw) error = None reload = (params.context or {}).get('reload', False) result = {} name = params.button_name btype = params.button_type ctx = dict((params.context or {}), **rpc.session.context) id = params.id model = params.model id = (id or False) and int(id) ids = (id or []) and [id] list_grid = params.list_grid or '_terp_list' try: if btype == 'workflow': res = rpc.session.execute('object', 'exec_workflow', model, name, id) if isinstance(res, dict): import actions return actions.execute(res, ids=[id]) else: return dict(reload=True, list_grid=list_grid) elif btype == 'object': ctx = params.context or {} ctx.update(rpc.session.context.copy()) if list_grid != '_terp_list': ctx['from_list_grid'] = list_grid res = rpc.session.execute('object', 'execute', model, name, ids, ctx) if isinstance(res, dict): import actions return actions.execute(res, ids=[id]) else: return dict(reload=True, list_grid=list_grid) elif btype == 'action': import actions action_id = int(name) action_type = actions.get_action_type(action_id) if action_type == 'ir.actions.wizard': cherrypy.session['wizard_parent_form'] = '/form' cherrypy.session['wizard_parent_params'] = params res = actions.execute_by_id(action_id, type=action_type, model=model, id=id, ids=ids, context=ctx or {}) if res: return res else: return dict(reload=True, list_grid=list_grid) else: return dict(error = "Unallowed button type") except Exception, e: return dict(error = ustr(e))
def button_action_action(self, name, params): model, id, ids, ctx = self._get_button_infos(params) import actions action_id = int(name) action_type = actions.get_action_type(action_id) if action_type == 'ir.actions.wizard': cherrypy.session['wizard_parent_form'] = self.path cherrypy.session['wizard_parent_params'] = params.parent_params or params res = actions.execute_by_id( action_id, type=action_type, model=model, id=id, ids=ids, context=ctx or {}) if res: return res params.button = None
def button_action_action(self, name, params): model, id, ids, ctx = self._get_button_infos(params) import actions action_id = int(name) action_type = actions.get_action_type(action_id) if action_type == 'ir.actions.wizard': cherrypy.session['wizard_parent_form'] = self.path cherrypy.session[ 'wizard_parent_params'] = params.parent_params or params res = actions.execute_by_id(action_id, type=action_type, model=model, id=id, ids=ids, context=ctx or {}) if res: return res params.button = None
def button_action(self, **kw): params, data = TinyDict.split(kw) error = None reload = (params.context or {}).get('reload', False) result = {} name = params.button_name btype = params.button_type ctx = dict((params.context or {}), **rpc.session.context) id = params.id model = params.model id = (id or False) and int(id) ids = (id or []) and [id] list_grid = params.list_grid or '_terp_list' try: if btype == 'workflow': res = rpc.session.execute('object', 'exec_workflow', model, name, id) if isinstance(res, dict): import actions return actions.execute(res, ids=[id]) else: return dict(reload=True, list_grid=list_grid) elif btype == 'object': ctx = params.context or {} ctx.update(rpc.session.context.copy()) res = rpc.session.execute('object', 'execute', model, name, ids, ctx) if isinstance(res, dict): import actions return actions.execute(res, ids=[id]) else: return dict(reload=True, list_grid=list_grid) elif btype == 'action': import actions action_id = int(name) action_type = actions.get_action_type(action_id) if action_type == 'ir.actions.wizard': cherrypy.session['wizard_parent_form'] = '/form' cherrypy.session['wizard_parent_params'] = params res = actions.execute_by_id(action_id, type=action_type, model=model, id=id, ids=ids, context=ctx or {}) if res: return res else: return dict(reload=True, list_grid=list_grid) else: return dict(error="Unallowed button type") except Exception, e: return dict(error=ustr(e))