summaryrefslogtreecommitdiff
path: root/odoo/modules/loading.py
diff options
context:
space:
mode:
authorChristophe Simonis <chs@odoo.com>2018-07-05 15:05:21 +0200
committerChristophe Simonis <chs@odoo.com>2018-07-05 15:05:21 +0200
commit92e5da6b8fdc6084edd863a5e02a8cd9bd33512c (patch)
treec3c3d0eadc9414b3c7a1ab5703bbabae2571aaac /odoo/modules/loading.py
parent30ede6a16afbb9f46033ef58c81ed7a7229959d4 (diff)
parent26e7d5d8eefaba958ad4b2d7c753c81cc968156a (diff)
[MERGE] forward port branch 10.0 up to 26e7d5d8eef
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 750c3388064..2c4f6a26e28 100644
--- a/odoo/modules/loading.py
+++ b/odoo/modules/loading.py
@@ -124,7 +124,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, partial=True)
+ migrations.migrate_module(package, 'pre')
+
load_openerp_module(package.name)
new_install = package.state == 'to install'
@@ -137,8 +147,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, partial=True)
@@ -158,7 +167,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.