diff options
| author | Raphael Collet <rco@openerp.com> | 2016-08-05 14:19:54 +0200 |
|---|---|---|
| committer | Raphael Collet <rco@openerp.com> | 2016-08-18 09:32:45 +0200 |
| commit | 58cde6c2fbcb71a1dc2142395761bbbe75fab7bf (patch) | |
| tree | 34edf5d496b9e4a2fa45dfb43a560d363a54d151 /openerp/modules/module.py | |
| parent | ecd9189684c9d4c7751219d292a46182467d1338 (diff) | |
[MIG] openerp.modules: convert code to the new API
Also, convert function `init_models` to a registry method.
Diffstat (limited to 'openerp/modules/module.py')
| -rw-r--r-- | openerp/modules/module.py | 31 |
1 files changed, 1 insertions, 30 deletions
diff --git a/openerp/modules/module.py b/openerp/modules/module.py index abc14bfc841..f1812d86350 100644 --- a/openerp/modules/module.py +++ b/openerp/modules/module.py @@ -18,11 +18,10 @@ import threading from operator import itemgetter from os.path import join as opj - import openerp import openerp.tools as tools import openerp.release as release -from openerp import SUPERUSER_ID +from openerp import SUPERUSER_ID, api from openerp.tools.safe_eval import safe_eval MANIFEST = '__openerp__.py' @@ -341,34 +340,6 @@ def load_information_from_description_file(module, mod_path=None): _logger.debug('module %s: no %s file found.', module, MANIFEST) return {} -def init_models(models, cr, context): - """ Initialize a list of models. - - 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. - - """ - if 'module' in context: - _logger.info('module %s: creating or updating database tables', context['module']) - context = dict(context, todo=[]) - models = [model.browse(cr, SUPERUSER_ID, [], context) for model in models] - 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'], key=itemgetter(0)): - func(*args) - if models: - models[0].recompute() - cr.commit() - def load_openerp_module(module_name): """ Load an OpenERP module, if not already loaded. |
