summaryrefslogtreecommitdiff
path: root/odoo/modules/loading.py
diff options
context:
space:
mode:
authorAdrian Torres <adt@odoo.com>2020-02-05 15:57:04 +0000
committerRaphael Collet <rco@odoo.com>2020-02-06 18:28:29 +0000
commitf61262eb08134ba5bdf9099445fe821769842bb3 (patch)
tree43dc1421445c45786d085fa3787ed579655e5ac2 /odoo/modules/loading.py
parentf6a1437aeb0c9e243d823450018d97b7c10385c6 (diff)
[FIX] core: delay constraint application in case of upgrade
closes odoo/odoo#44800 Co-authored-with: Xavier Dollé <xdo@odoo.com> X-original-commit: bc2bb5e03c2b32d4ee1b0597ea5889c17d2b0e0e Signed-off-by: Xavier Dollé (xdo) <xdo@odoo.com>
Diffstat (limited to 'odoo/modules/loading.py')
-rw-r--r--odoo/modules/loading.py13
1 files changed, 8 insertions, 5 deletions
diff --git a/odoo/modules/loading.py b/odoo/modules/loading.py
index 9b1efca7cc4..7e20af9033e 100644
--- a/odoo/modules/loading.py
+++ b/odoo/modules/loading.py
@@ -187,12 +187,16 @@ def load_module_graph(cr, graph, status=None, perform_checks=True,
model_names = registry.load(cr, package)
+ mode = 'update'
+ if hasattr(package, 'init') or package.state == 'to install':
+ mode = 'init'
+
loaded_modules.append(package.name)
if needs_update:
models_updated |= set(model_names)
models_to_check -= set(model_names)
registry.setup_models(cr)
- registry.init_models(cr, model_names, {'module': package.name})
+ registry.init_models(cr, model_names, {'module': package.name}, mode)
elif package.state != 'to remove':
# The current module has simply been loaded. The models extended by this module
# and for which we updated the schema, must have their schema checked again.
@@ -203,10 +207,6 @@ def load_module_graph(cr, graph, status=None, perform_checks=True,
idref = {}
- mode = 'update'
- if hasattr(package, 'init') or package.state == 'to install':
- mode = 'init'
-
if needs_update:
env = api.Environment(cr, SUPERUSER_ID, {})
# Can't put this line out of the loop: ir.module.module will be
@@ -438,6 +438,9 @@ def load_modules(db, force_demo=False, status=None, update_module=False):
for package in graph:
migrations.migrate_module(package, 'end')
+ # STEP 3.6: apply remaining constraints in case of an upgrade
+ registry.finalize_constraints()
+
# STEP 4: Finish and cleanup installations
if processed_modules:
env = api.Environment(cr, SUPERUSER_ID, {})