'Install the requested modules.
:param modules: a list of tuples (module_name, module_record)
:return: the next action to execute'

@api.model
def _install_modules(self, modules):

    to_install_modules = self.env['ir.module.module']
    to_install_missing_names = []
    for (name, module) in modules:
        if (not module):
            to_install_missing_names.append(name)
        elif (module.state == 'uninstalled'):
            to_install_modules += module
    result = None
    if to_install_modules:
        result = to_install_modules.button_immediate_install()
    if to_install_missing_names:
        return {'type': 'ir.actions.client', 'tag': 'apps', 'params': {'modules': to_install_missing_names}}
    return result
