summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--odoo/tests/common.py5
1 files changed, 5 insertions, 0 deletions
diff --git a/odoo/tests/common.py b/odoo/tests/common.py
index 706626394db..59c4cd334b5 100644
--- a/odoo/tests/common.py
+++ b/odoo/tests/common.py
@@ -493,6 +493,11 @@ class SavepointCase(SingleTransactionCase):
super(SavepointCase, self).setUp()
self._savepoint_id = next(savepoint_seq)
self.cr.execute('SAVEPOINT test_%d' % self._savepoint_id)
+ # restore environments after the test to avoid invoking flush() with an
+ # invalid environment (inexistent user id) from another test
+ envs = self.env.all.envs
+ self.addCleanup(envs.update, list(envs))
+ self.addCleanup(envs.clear)
def tearDown(self):
self.cr.execute('ROLLBACK TO SAVEPOINT test_%d' % self._savepoint_id)