Skip to content

Commit

Permalink
[FIX] odoo-bin shell: force rollback on exit
Browse files Browse the repository at this point in the history
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
  • Loading branch information
KangOl committed Apr 14, 2017
1 parent 31dc6b8 commit ea2faef
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions odoo/cli/shell.py
Expand Up @@ -14,6 +14,25 @@
_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()

Expand Down Expand Up @@ -95,6 +114,7 @@ def shell(self, dbname):
local_vars['env'] = env
local_vars['self'] = env.user
self.console(local_vars)
cr.rollback()
else:
self.console(local_vars)

Expand Down

0 comments on commit ea2faef

Please sign in to comment.