[FIX] odoo-bin shell: force rollback on exit

Each REPL python shell behave differently depending on the exit method.
Force a rollback at the end to avoid inconsitent behavior.

Thanks to Harry Jollenbeck for the report: https://www.odoo.com/groups/59/26318707
This commit is contained in:
Christophe Simonis
2017-04-14 12:38:51 +02:00
parent 31dc6b888e
commit ea2faefe0d
+20
View File
@@ -14,6 +14,25 @@ from . import Command
_logger = logging.getLogger(__name__)
"""
Shell exit behaviors
====================
Legend:
stop = The REPL main loop stop.
raise = Exception raised.
loop = Stay in REPL.
Shell | ^D | exit() | quit() | sys.exit() | raise SystemExit()
----------------------------------------------------------------------
python | stop | raise | raise | raise | raise
ipython | stop | stop | stop | loop | loop
ptpython | stop | raise | raise | raise | raise
bpython | stop | stop | stop | stop | stop
"""
def raise_keyboard_interrupt(*a):
raise KeyboardInterrupt()
@@ -95,6 +114,7 @@ class Shell(Command):
local_vars['env'] = env
local_vars['self'] = env.user
self.console(local_vars)
cr.rollback()
else:
self.console(local_vars)