def executeKeyword(keyword, data=None, context=None): if data is None: data = {} if context is None: context = {} actions = None if 'id' in data: try: id = data.get('id', False) actions = Rpc.session.execute('/object', 'execute', 'ir.values', 'get', 'action', keyword, [(data['model'], id)], False, Rpc.session.context) actions = [x[2] for x in actions] except Rpc.RpcException as e: return None if not actions: return None keyact = {} for action in actions: keyact[action['name']] = action res = Common.selection(_('Select your action'), keyact) if not res: return None (name, action) = res Api.instance.executeAction(action, data, context=context) return (name, action)
def executeKeyword(keyword, data=None, context=None): """ Executes the given keyword action (it could be a report, wizard, etc). :param keyword: :param data: :param context: :return: Name, action :rtype: tuple """ if data is None: data = {} if context is None: context = {} actions = None if 'id' in data: try: ident = data.get('id', False) actions = Rpc.session.execute('/object', 'execute', 'ir.values', 'get', 'action', keyword, [(data['model'], ident)], False, Rpc.session.context) actions = [x[2] for x in actions] except Rpc.RpcException: return None if not actions: return None keyact = {} for action in actions: keyact[action['name']] = action res = Common.selection(_('Select your action'), keyact) if not res: return None (name, action) = res Api.instance.executeAction(action, data, context=context) return name, action
if data is None: data = {} if context is None: context = {} actions = None if 'id' in data: try: id = data.get('id', False) actions = Rpc.session.execute('/object', 'execute', 'ir.values', 'get', 'action', keyword, [(data['model'], id)], False, Rpc.session.context) if (actions): actions = map(lambda x: x[2], actions) except Rpc.RpcException, e: return None if not actions: return None keyact = {} for action in actions: keyact[action['name']] = action res = Common.selection(_('Select your action'), keyact) if not res: return None (name,action) = res Api.instance.executeAction(action, data, context=context) return (name, action)