summaryrefslogtreecommitdiff
path: root/odoo/modules/loading.py
diff options
context:
space:
mode:
authorChristophe Simonis <chs@odoo.com>2018-07-05 19:33:14 +0200
committerChristophe Simonis <chs@odoo.com>2018-07-05 19:33:14 +0200
commit8db9865c2d5bf09b735fa8d59bc11e511927619b (patch)
tree05da09c5735e8cfe74f36a15ef6f448f587007f2 /odoo/modules/loading.py
parentceaa6562a585e4098c0981812e47d120d7c9f96e (diff)
parent2214bffefb26ce033ec145bce9edabacc342fe02 (diff)
[MERGE] forward port branch saas-11.3 up to 2214bffefb2
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.