summaryrefslogtreecommitdiff
path: root/odoo/modules/loading.py
diff options
context:
space:
mode:
authorChristophe Simonis <chs@odoo.com>2018-07-05 17:21:01 +0200
committerChristophe Simonis <chs@odoo.com>2018-07-05 17:21:01 +0200
commit45329c0cf2c5158f7c7ccdae888adbaf2e15e7ca (patch)
tree350d68b091b113ea31f551b05d2d82991259b6a9 /odoo/modules/loading.py
parent43e4d63d069e16e64a768ef4742a5d4fca177f0c (diff)
parent84210074e55d906ea3c36e3a79741f83c5a55215 (diff)
[MERGE] forward port branch 11.0 up to 84210074e55
Diffstat (limited to 'odoo/modules/loading.py')
-rw-r--r--odoo/modules/loading.py17
1 files changed, 13 insertions, 4 deletions
diff --git a/odoo/modules/loading.py b/odoo/modules/loading.py
index b9f4e2fdc7b..6e123324635 100644
--- a/odoo/modules/loading.py
+++ b/odoo/modules/loading.py
@@ -120,7 +120,17 @@ def load_module_graph(cr, graph, status=None, perform_checks=True,
continue
_logger.debug('loading module %s (%d/%d)', module_name, index, module_count)
- migrations.migrate_module(package, 'pre')
+
+ needs_update = (
+ hasattr(package, "init")
+ or hasattr(package, "update")
+ or package.state in ("to install", "to upgrade")
+ )
+ if needs_update:
+ if package.name != 'base':
+ registry.setup_models(cr)
+ migrations.migrate_module(package, 'pre')
+
load_openerp_module(package.name)
new_install = package.state == 'to install'
@@ -133,8 +143,7 @@ def load_module_graph(cr, graph, status=None, perform_checks=True,
model_names = registry.load(cr, package)
loaded_modules.append(package.name)
- if (hasattr(package, 'init') or hasattr(package, 'update')
- or package.state in ('to install', 'to upgrade')):
+ if needs_update:
models_updated |= set(model_names)
models_to_check -= set(model_names)
registry.setup_models(cr)
@@ -154,7 +163,7 @@ def load_module_graph(cr, graph, status=None, perform_checks=True,
if hasattr(package, 'init') or package.state == 'to install':
mode = 'init'
- if hasattr(package, 'init') or hasattr(package, 'update') or package.state in ('to install', 'to upgrade'):
+ if needs_update:
env = api.Environment(cr, SUPERUSER_ID, {})
# Can't put this line out of the loop: ir.module.module will be
# registered by init_models() above.