summaryrefslogtreecommitdiff
path: root/odoo/modules
diff options
context:
space:
mode:
authorRaphael Collet <rco@odoo.com>2020-02-10 13:22:56 +0000
committerRaphael Collet <rco@odoo.com>2020-02-12 11:17:54 +0000
commitc8e79869a37b87101d64e4703401f409358a2099 (patch)
tree3c4bce683fb85b9a57f3460bfb0ba993a4447f09 /odoo/modules
parent5e01d97b1d15510209f215352b96f5b406a7a0ed (diff)
[FIX] core: delay of constraints in upgrade
Sometimes, constraints are not delayed during a module upgrade: the module is 'to upgrade' but in 'init' mode :-/ Fix this by relying on the module's state only. closes odoo/odoo#45179 X-original-commit: 878b6538961a9b6a5fe1c6ac68d4ff39391abcdf Signed-off-by: Xavier Dollé (xdo) <xdo@odoo.com>
Diffstat (limited to 'odoo/modules')
-rw-r--r--odoo/modules/loading.py2
-rw-r--r--odoo/modules/registry.py6
2 files changed, 4 insertions, 4 deletions
diff --git a/odoo/modules/loading.py b/odoo/modules/loading.py
index 5c388026a20..8b6b5a7ea9c 100644
--- a/odoo/modules/loading.py
+++ b/odoo/modules/loading.py
@@ -199,7 +199,7 @@ def load_module_graph(cr, graph, status=None, perform_checks=True,
models_updated |= set(model_names)
models_to_check -= set(model_names)
registry.setup_models(cr)
- registry.init_models(cr, model_names, {'module': package.name}, mode)
+ registry.init_models(cr, model_names, {'module': package.name}, new_install)
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.
diff --git a/odoo/modules/registry.py b/odoo/modules/registry.py
index 0dfe94041f4..9b39758a30a 100644
--- a/odoo/modules/registry.py
+++ b/odoo/modules/registry.py
@@ -316,7 +316,7 @@ class Registry(Mapping):
try:
func(*args, **kwargs)
except Exception as e:
- if self._mode == 'init':
+ if self._is_install:
_schema.error(*e.args)
else:
_schema.info(*e.args)
@@ -331,7 +331,7 @@ class Registry(Mapping):
except Exception as e:
_schema.error(*e.args)
- def init_models(self, cr, model_names, context, mode='init'):
+ def init_models(self, cr, model_names, context, install=True):
""" Initialize a list of models (given by their name). Call methods
``_auto_init`` and ``init`` on each model to create or update the
database tables supporting the models.
@@ -350,7 +350,7 @@ class Registry(Mapping):
# make sure the queue does not contain some leftover from a former call
self._post_init_queue.clear()
- self._mode = mode
+ self._is_install = install
for model in models:
model._auto_init()