[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) <juc@odoo.com>
This commit is contained in:
Julien Castiaux
2023-05-25 19:16:40 +02:00
parent 504b969210
commit c207b40b51
2 changed files with 6 additions and 1 deletions
+4
View File
@@ -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
+2 -1
View File
@@ -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