summaryrefslogtreecommitdiff
path: root/addons
diff options
context:
space:
mode:
authorRaphael Collet <rco@odoo.com>2020-04-02 13:59:21 +0000
committerRaphael Collet <rco@odoo.com>2020-04-02 23:54:32 +0000
commit962412c309528785bcbaeadfe69eeee740932f85 (patch)
tree7ecc05dec1e7156b3c9a68e34214f855305ce459 /addons
parent46b7fb598498dfe8673268e82944488b741f5caa (diff)
[FIX] test_website: upgrading inside a test is really not a good idea
Because: (1) the upgrade starts by committing the current cursor; then (2) the upgrade instanciates a new registry to use for the database; and (3) the test cleanup involves setting up the old registry, which creates a new environment referring to the new registry! The points (2) and (3) makes the field setup crash when it relies on data stored on the registry itself: the field in the old registry tries to set up with data stored on the old registry. closes odoo/odoo#48920 X-original-commit: f5e5aba9e203b42b661cc3b503fd37051ec20f93 Signed-off-by: Raphael Collet (rco) <rco@openerp.com>
Diffstat (limited to 'addons')
-rw-r--r--addons/test_website/tests/test_views_during_module_operation.py6
1 files changed, 6 insertions, 0 deletions
diff --git a/addons/test_website/tests/test_views_during_module_operation.py b/addons/test_website/tests/test_views_during_module_operation.py
index 530284e2645..e960291bf22 100644
--- a/addons/test_website/tests/test_views_during_module_operation.py
+++ b/addons/test_website/tests/test_views_during_module_operation.py
@@ -62,6 +62,12 @@ class TestViewsDuringModuleOperation(TransactionCase):
self.assertTrue(self.env.ref(update_module_view_to_be_t_called.key))
self.assertTrue(self.env.ref(update_module_base_view.key))
+ # the upgrade of the module below instanciates a NEW registry, so we
+ # have to restore the old one in order to perform the cleanups
+ @self.addCleanup
+ def cleanup():
+ self.registry.registries[self.registry.db_name] = self.registry
+
# Update the module
test_website_module = self.env['ir.module.module'].search([('name', '=', 'test_website')])
test_website_module.button_immediate_upgrade()