'Initialize a list of models (given by their name). Call methods
``_auto_init``, ``init``, and ``_auto_end`` on each model to create
or update the database tables supporting the models.
The ``context`` may contain the following items:
- ``module``: the name of the module being installed/updated, if any;
- ``update_custom_fields``: whether custom fields should be updated.'

def init_models(self, cr, model_names, context):

    if ('module' in context):
        _logger.info('module    %s:    creating    or    updating    database    tables', context['module'])
    context = dict(context, todo=[])
    env = odoo.api.Environment(cr, SUPERUSER_ID, context)
    models = [env[model_name] for model_name in model_names]
    for model in models:
        model._auto_init()
        model.init()
        cr.commit()
    for model in models:
        model._auto_end()
        cr.commit()
    for (_, func, args) in sorted(context['todo']):
        func(*args)
    if models:
        models[0].recompute()
    cr.commit()
    missing = [name for (name, model) in env.items() if ((not model._abstract) and (not model._table_exist()))]
    if missing:
        _logger.warning('Models    have    no    table:    %s.', ',    '.join(missing))
        deps = {name: model._depends for (name, model) in env.items()}
        for name in topological_sort(deps):
            if (name in missing):
                _logger.info('Recreate    table    of    model    %s.', name)
                env[name].init()
                cr.commit()
        for (name, model) in env.items():
            if ((not model._abstract) and (not model._table_exist())):
                _logger.error('Model    %s    has    no    table.', name)
