[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:
@@ -413,10 +413,17 @@ class Cursor(object):
|
|||||||
def savepoint(self):
|
def savepoint(self):
|
||||||
"""context manager entering in a new savepoint"""
|
"""context manager entering in a new savepoint"""
|
||||||
name = uuid.uuid1().hex
|
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)
|
self.execute('SAVEPOINT "%s"' % name)
|
||||||
try:
|
try:
|
||||||
yield
|
yield
|
||||||
|
if env is not None:
|
||||||
|
env['base'].flush()
|
||||||
except Exception:
|
except Exception:
|
||||||
|
if env is not None:
|
||||||
|
env.clear()
|
||||||
self.execute('ROLLBACK TO SAVEPOINT "%s"' % name)
|
self.execute('ROLLBACK TO SAVEPOINT "%s"' % name)
|
||||||
raise
|
raise
|
||||||
else:
|
else:
|
||||||
|
|||||||
Reference in New Issue
Block a user