[FIX] sql_db: revert ee03fc3770

ee03fc3770 introduced a non deterministic bug by choosing an
environment in a set, so the environment is not always the good one.

closes odoo/odoo#36056

Signed-off-by: Raphael Collet (rco) <rco@openerp.com>
This commit is contained in:
Christophe Monniez
2019-08-26 08:18:40 +00:00
parent ff52295c74
commit cdb904e059
-7
View File
@@ -413,17 +413,10 @@ class Cursor(object):
def savepoint(self):
"""context manager entering in a new savepoint"""
name = uuid.uuid1().hex
env = next((e for e in Environment.envs if e.cr is self), None)
if env is not None:
env['base'].flush()
self.execute('SAVEPOINT "%s"' % name)
try:
yield
if env is not None:
env['base'].flush()
except Exception:
if env is not None:
env.clear()
self.execute('ROLLBACK TO SAVEPOINT "%s"' % name)
raise
else: