From 571276eb660b58a56f4680f2ba933aa28f521d11 Mon Sep 17 00:00:00 2001 From: Antonin Bourguignon Date: Fri, 18 Jan 2013 16:24:20 +0100 Subject: [PATCH 1/3] [IMP] introduce a new type of exception: WarningConfig. Note that no corresponding RPC_FAULT_CODE has been added; WarningConfig will share the same RPC_FAULT_CODE than Warning (RPC_FAULT_CODE_WARNING = 2) bzr revid: abo@openerp.com-20130118152420-9wk5nwuydwdwzoge --- addons/web/session.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/addons/web/session.py b/addons/web/session.py index 30e9308d4e1..a2719482a2c 100644 --- a/addons/web/session.py +++ b/addons/web/session.py @@ -92,6 +92,8 @@ class OpenERPSession(object): raise xmlrpclib.Fault(code_string % (e.name, e.value), '') except openerp.exceptions.Warning, e: raise xmlrpclib.Fault(code_string % ("Warning", e), '') + except openerp.exceptions.WarningConfig, e: + raise xmlrpclib.Fault(code_string % ("Warning", e), '') except openerp.exceptions.AccessError, e: raise xmlrpclib.Fault(code_string % ("AccessError", e), '') except openerp.exceptions.AccessDenied, e: From 75ce079a814f8795d43171965a842aa19a51b2f3 Mon Sep 17 00:00:00 2001 From: Antonin Bourguignon Date: Thu, 24 Jan 2013 16:41:19 +0100 Subject: [PATCH 2/3] [IMP] we don't need a special type of exception anymore bzr revid: abo@openerp.com-20130124154119-flmuzwunpi72c02i --- addons/web/session.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/addons/web/session.py b/addons/web/session.py index a2719482a2c..30e9308d4e1 100644 --- a/addons/web/session.py +++ b/addons/web/session.py @@ -92,8 +92,6 @@ class OpenERPSession(object): raise xmlrpclib.Fault(code_string % (e.name, e.value), '') except openerp.exceptions.Warning, e: raise xmlrpclib.Fault(code_string % ("Warning", e), '') - except openerp.exceptions.WarningConfig, e: - raise xmlrpclib.Fault(code_string % ("Warning", e), '') except openerp.exceptions.AccessError, e: raise xmlrpclib.Fault(code_string % ("AccessError", e), '') except openerp.exceptions.AccessDenied, e: From 62285a48ed6d6ecba3776b994a10ad217d527f31 Mon Sep 17 00:00:00 2001 From: Antonin Bourguignon Date: Thu, 31 Jan 2013 19:29:21 +0100 Subject: [PATCH 3/3] [IMP] add a handler for the new exception RedirectWarning bzr revid: abo@openerp.com-20130131182921-9tv71vzjr2agdusc --- addons/web/static/src/js/chrome.js | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/addons/web/static/src/js/chrome.js b/addons/web/static/src/js/chrome.js index 1407df4d33f..86d0a20ed20 100644 --- a/addons/web/static/src/js/chrome.js +++ b/addons/web/static/src/js/chrome.js @@ -327,6 +327,34 @@ instance.web.ExceptionHandler = { */ instance.web.crash_manager_registry = new instance.web.Registry(); +/** + * Handle redirection warnings, which behave more or less like a regular + * warning, with an additional redirection button. + */ +instance.web.RedirectWarningHandler = instance.web.Dialog.extend(instance.web.ExceptionHandler, { + init: function(parent, error) { + this._super(parent); + this.error = error; + }, + display: function() { + error = this.error; + error.data.message = error.data.arguments[0]; + + instance.web.dialog($('
' + QWeb.render('CrashManager.warning', {error: error}) + '
'), { + title: "OpenERP " + (_.str.capitalize(error.type) || "Warning"), + buttons: [ + {text: _t("Ok"), click: function() { $(this).dialog("close"); }}, + {text: error.data.arguments[2], click: function() { + window.location.href='#action='+error.data.arguments[1]; + $(this).dialog("close"); + }} + ] + }); + this.destroy(); + } +}); +instance.web.crash_manager_registry.add('openerp.exceptions.RedirectWarning', 'instance.web.RedirectWarningHandler'); + instance.web.Loading = instance.web.Widget.extend({ template: _t("Loading"), init: function(parent) {