[FIX] sql_db: flush in savepoint, following odoo/odoo@9920f20e4c

closes odoo/odoo#35986

Signed-off-by: Raphael Collet (rco) <rco@openerp.com>
This commit is contained in:
Denis Ledoux
2019-08-23 10:07:05 +00:00
parent d61cb18895
commit ee03fc3770
+7
View File
@@ -413,10 +413,17 @@ 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: