[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):
|
||||
"""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:
|
||||
|
||||
Reference in New Issue
Block a user