示例#1
0
文件: main.py 项目: masking/tryton
    def exec_keyword(keyword,
                     data=None,
                     context=None,
                     warning=True,
                     alwaysask=False):
        actions = []
        model_id = data.get('id', False)
        try:
            actions = RPCExecute('model', 'ir.action.keyword', 'get_keyword',
                                 keyword, (data['model'], model_id))
        except RPCException:
            return False

        keyact = {}
        for action in actions:
            keyact[action['name'].replace('_', '')] = action

        res = selection(_('Select your action'), keyact, alwaysask=alwaysask)
        if res:
            (name, action) = res
            Action._exec_action(action, data, context=context)
            return (name, action)
        elif not len(keyact) and warning:
            message(_('No action defined.'))
        return False
def execute(datas):
    result = {}

    for module in MODULES:
        for name, func in module.get_plugins(datas['model']):
            result[name] = func
    if not result:
        common.message(_('No available plugin for this resource!'))
        return False
    res = common.selection(_('Choose a Plugin'), result, alwaysask=True)
    if res:
        res[1](datas)
    return True
示例#3
0
    def exec_keyword(keyword, data=None, context=None, warning=True,
            alwaysask=False):
        actions = []
        model_id = data.get('id', False)
        try:
            actions = RPCExecute('model', 'ir.action.keyword',
                'get_keyword', keyword, (data['model'], model_id))
        except RPCException:
            return False

        keyact = {}
        for action in actions:
            keyact[action['name'].replace('_', '')] = action

        res = selection(_('Select your action'), keyact, alwaysask=alwaysask)
        if res:
            (name, action) = res
            Action._exec_action(action, data, context=context)
            return (name, action)
        elif not len(keyact) and warning:
            message(_('No action defined!'))
        return False