From ea2faefe0d6a4a6063d48fc2cda8d7071d9eefa4 Mon Sep 17 00:00:00 2001 From: Christophe Simonis Date: Fri, 14 Apr 2017 12:27:43 +0200 Subject: [PATCH] [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 --- odoo/cli/shell.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/odoo/cli/shell.py b/odoo/cli/shell.py index 6d0b0d5bd01c9..1e8478009561f 100644 --- a/odoo/cli/shell.py +++ b/odoo/cli/shell.py @@ -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() @@ -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)