From c207b40b51ddb26209f0f0747fa5eebcdb02a640 Mon Sep 17 00:00:00 2001 From: Julien Castiaux Date: Wed, 24 May 2023 10:55:50 +0000 Subject: [PATCH] [FIX] base: reniew request registry after uninstall Install and then uninstall the utm module via the web client, you get a traceback because the ir.http override of the utm module is still present in the registry altought the module is not installed anymore. The problem affects all modules that override the _post_dispatch method of ir.http, it is not limited to UTM. The problem is that, after the uninstallation, a new registry (without the uninstalled modules) is created but the old registry was still used by the HTTP stack. closes odoo/odoo#122519 Closes: #121755 X-original-commit: 979844600a0bc5ea8b63cf4d58c7aba5133e82f3 Signed-off-by: Julien Castiaux (juc) --- odoo/addons/base/models/ir_module.py | 4 ++++ odoo/http.py | 3 ++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/odoo/addons/base/models/ir_module.py b/odoo/addons/base/models/ir_module.py index 0afa6c0823c..1305833fac7 100644 --- a/odoo/addons/base/models/ir_module.py +++ b/odoo/addons/base/models/ir_module.py @@ -599,6 +599,10 @@ class Module(models.Model): self._cr.commit() registry = modules.registry.Registry.new(self._cr.dbname, update_module=True) self._cr.commit() + if request and request.registry is self.env.registry: + request.env.cr.reset() + request.registry = request.env.registry + assert request.env.registry is registry self._cr.reset() assert self.env.registry is registry diff --git a/odoo/http.py b/odoo/http.py index 2ba32a74840..f496ceca403 100644 --- a/odoo/http.py +++ b/odoo/http.py @@ -1723,7 +1723,8 @@ class Request: ir_http._authenticate(rule.endpoint) ir_http._pre_dispatch(rule, args) response = self.dispatcher.dispatch(rule.endpoint, args) - ir_http._post_dispatch(response) + # the registry can have been reniewed by dispatch + self.registry['ir.http']._post_dispatch(response) return response