From 83a0c46dbb6e66418b763453d6eb403161e3a79c Mon Sep 17 00:00:00 2001 From: Raphael Collet Date: Fri, 15 Nov 2019 14:47:33 +0000 Subject: [PATCH] [FIX] registry: init_models() using a closed cursor When a call to init_models() fails, the post-init queue still contains callables that refer to a soon-to-be-closed cursor. If one calls init_models() in another request, the post-init process will inevitably fail because it refers to closed cursors. closes odoo/odoo#40379 X-original-commit: 33f87ffebaa1cb38e3ce8ce44c8b8b538b49e5b9 Signed-off-by: Raphael Collet (rco) --- odoo/modules/registry.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/odoo/modules/registry.py b/odoo/modules/registry.py index 19124738624..dc03d0b24d3 100644 --- a/odoo/modules/registry.py +++ b/odoo/modules/registry.py @@ -313,6 +313,9 @@ class Registry(Mapping): env = odoo.api.Environment(cr, SUPERUSER_ID, context) models = [env[model_name] for model_name in model_names] + # make sure the queue does not contain some leftover from a former call + self._post_init_queue.clear() + for model in models: model._auto_init() model.init()