[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>
This commit is contained in:
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user