From c8e79869a37b87101d64e4703401f409358a2099 Mon Sep 17 00:00:00 2001 From: Raphael Collet Date: Mon, 10 Feb 2020 13:22:56 +0000 Subject: [PATCH] [FIX] core: delay of constraints in upgrade MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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) --- odoo/modules/loading.py | 2 +- odoo/modules/registry.py | 6 +++--- 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()