diff --git a/tryton/tryton/common/common.py b/tryton/tryton/common/common.py index 8d4b964f8a..010729b8a3 100644 --- a/tryton/tryton/common/common.py +++ b/tryton/tryton/common/common.py @@ -1001,10 +1001,13 @@ def process_exception(exception, *args, **kwargs): name, msg, description = exception.args res = userwarning(description, msg) if res in ('always', 'ok'): - RPCExecute( - 'model', 'res.user.warning', 'skip', - name, (res == 'always'), - process_exception=False) + try: + RPCExecute( + 'model', 'res.user.warning', 'skip', + name, (res == 'always'), + process_exception=False) + except RPCException: + pass return rpc_execute(*args) elif exception.faultCode == 'UserError': msg, description, domain = exception.args diff --git a/tryton/tryton/common/completion.py b/tryton/tryton/common/completion.py index e8bb0d7b6e..390cb43c68 100644 --- a/tryton/tryton/common/completion.py +++ b/tryton/tryton/common/completion.py @@ -5,7 +5,7 @@ import logging from gi.repository import GLib, Gtk -from tryton.common import RPCExecute +from tryton.common import RPCException, RPCExecute from tryton.config import CONFIG from tryton.exceptions import TrytonError, TrytonServerError @@ -72,7 +72,7 @@ def update_completion(entry, record, field, model, domain=None): 'model', model, 'autocomplete', search_text, domain, CONFIG['client.limit'], order, context=context, process_exception=False, callback=callback) - except Exception: + except RPCException: logger.warning( "Unable to search for completion of %s", model, exc_info=True) diff --git a/tryton/tryton/device_cookie.py b/tryton/tryton/device_cookie.py index 473efdf06b..fba1b912dd 100644 --- a/tryton/tryton/device_cookie.py +++ b/tryton/tryton/device_cookie.py @@ -20,7 +20,7 @@ def renew(): def set_cookie(new_cookie): try: new_cookie = new_cookie() - except Exception: + except common.RPCException: logger.error("Cannot renew device cookie", exc_info=True) else: _set(new_cookie) diff --git a/tryton/tryton/gui/main.py b/tryton/tryton/gui/main.py index 1b979831b0..bc0d825e0b 100644 --- a/tryton/tryton/gui/main.py +++ b/tryton/tryton/gui/main.py @@ -23,8 +23,7 @@ from tryton.common import RPCContextReload, RPCException, RPCExecute from tryton.common.cellrendererclickablepixbuf import ( CellRendererClickablePixbuf) from tryton.config import CONFIG, TRYTON_ICON, get_config_dir -from tryton.exceptions import ( - TrytonError, TrytonServerError, TrytonServerUnavailable) +from tryton.exceptions import TrytonError, TrytonServerUnavailable from tryton.gui.window import Window from tryton.jsonrpc import object_hook from tryton.pyson import PYSONDecoder @@ -376,7 +375,7 @@ class Main(Gtk.Application): def set_result(result): try: result = result() - except (RPCException, TrytonServerError): + except RPCException: result = [] if search_text != widget.get_text(): if callback: @@ -472,7 +471,7 @@ class Main(Gtk.Application): favorites = RPCExecute('model', self.menu_screen.model_name + '.favorite', 'get', process_exception=False) - except Exception: + except RPCException: return False for id_, name, icon in favorites: menuitem = Gtk.MenuItem(label=name) diff --git a/tryton/tryton/gui/window/email_.py b/tryton/tryton/gui/window/email_.py index abada7ce19..7377b582c8 100644 --- a/tryton/tryton/gui/window/email_.py +++ b/tryton/tryton/gui/window/email_.py @@ -74,7 +74,7 @@ class EmailEntry(Gtk.Entry): RPCExecute( 'model', 'ir.email', 'complete', text, CONFIG['client.limit'], process_exception=False, callback=callback) - except Exception: + except RPCException: logger.warning( _("Unable to complete email entry"), exc_info=True) return False diff --git a/tryton/tryton/gui/window/view_form/model/record.py b/tryton/tryton/gui/window/view_form/model/record.py index 40e12ebab8..7b592a9946 100644 --- a/tryton/tryton/gui/window/view_form/model/record.py +++ b/tryton/tryton/gui/window/view_form/model/record.py @@ -7,7 +7,6 @@ import operator import tryton.common as common from tryton.common import RPCException, RPCExecute from tryton.config import CONFIG -from tryton.exceptions import TrytonServerError from tryton.pyson import PYSONDecoder from . import field as fields @@ -720,7 +719,7 @@ class Record: 'model', self.model_name, 'autocomplete_' + fieldname, args, context=self.get_context(), process_exception=False) - except (RPCException, TrytonServerError): + except RPCException: # ensure res is a list res = [] self.autocompletion[fieldname] = res @@ -728,9 +727,12 @@ class Record: def on_scan_code(self, code, depends): depends = self.expr_eval(depends) values = self._get_on_change_args(depends) - changes = RPCExecute( - 'model', self.model_name, 'on_scan_code', values, code, - context=self.get_context(), process_exception=False) + try: + changes = RPCExecute( + 'model', self.model_name, 'on_scan_code', values, code, + context=self.get_context(), process_exception=False) + except RPCException: + changes = [] self.set_on_change(changes) self.set_modified() return bool(changes) diff --git a/tryton/tryton/gui/window/view_form/screen/screen.py b/tryton/tryton/gui/window/view_form/screen/screen.py index 1d3c7a4290..f04e9f273b 100644 --- a/tryton/tryton/gui/window/view_form/screen/screen.py +++ b/tryton/tryton/gui/window/view_form/screen/screen.py @@ -21,7 +21,6 @@ from tryton.common import ( from tryton.common.domain_inversion import canonicalize from tryton.common.domain_parser import DomainParser from tryton.config import CONFIG -from tryton.exceptions import TrytonServerError from tryton.gui.window.infobar import InfoBar from tryton.gui.window.view_form.model.group import Group from tryton.gui.window.view_form.view import View @@ -310,7 +309,7 @@ class Screen: 'model', self.model_name, 'search_count', domain, 0, self.count_limit, context=context, process_exception=False) - except (RPCException, TrytonServerError): + except RPCException: self.search_count = 0 else: self.search_count = len(ids) @@ -936,7 +935,7 @@ class Screen: json_paths, json_selected_path, process_exception=False) clear_cache('model.ir.ui.view_tree_state.get') - except Exception: + except RPCException: logger.warn( _('Unable to set view tree state'), exc_info=True) diff --git a/tryton/tryton/gui/window/view_form/view/form_gtk/state_widget.py b/tryton/tryton/gui/window/view_form/view/form_gtk/state_widget.py index 9657269d36..3200e409c9 100644 --- a/tryton/tryton/gui/window/view_form/view/form_gtk/state_widget.py +++ b/tryton/tryton/gui/window/view_form/view/form_gtk/state_widget.py @@ -7,7 +7,6 @@ from gi.repository import Gtk import tryton.common as common from tryton.action import Action from tryton.config import CONFIG -from tryton.exceptions import TrytonServerError from tryton.pyson import PYSONDecoder @@ -209,7 +208,7 @@ class Link(StateMixin, Gtk.Button): if count > 99: count = '99+' counter[idx] = count - except (common.RPCException, TrytonServerError): + except common.RPCException: pass self._set_label_counter(label, counter) diff --git a/tryton/tryton/gui/window/wizard.py b/tryton/tryton/gui/window/wizard.py index a23b4c7518..24791855e9 100644 --- a/tryton/tryton/gui/window/wizard.py +++ b/tryton/tryton/gui/window/wizard.py @@ -150,16 +150,17 @@ class Wizard(InfoBar): def end(self, callback=None): def end_callback(action): - self.destroy(action=action()) - if callback: - callback() - try: - RPCExecute('wizard', self.action, 'delete', self.session_id, - process_exception=False, callback=end_callback) - except Exception: - logger.warn( - "Unable to delete session %s of wizard %s", - self.session_id, self.action, exc_info=True) + try: + self.destroy(action=action()) + if callback: + callback() + except RPCException: + logger.warn( + "Unable to delete session %s of wizard %s", + self.session_id, self.action, exc_info=True) + RPCExecute( + 'wizard', self.action, 'delete', self.session_id, + process_exception=False, callback=end_callback) def clean(self): for widget in self.widget.get_children():