From e6d4ab84da7a1031ab552b4a6b3fc4aa2348163e Mon Sep 17 00:00:00 2001
From: fja-odoo
Date: Tue, 11 Jun 2019 12:26:41 +0000
Subject: [PATCH 1/9] [REF] web: move rpc_error binding into the crash_manager
Moving the rpc_error binding into the crash manager is mandatory for it
to be used in the website.
Part of https://github.com/odoo/odoo/pull/32132
task-1894820
---
.../src/js/chrome/abstract_web_client.js | 40 -------------------
.../static/src/js/services/crash_manager.js | 40 +++++++++++++++++++
2 files changed, 40 insertions(+), 40 deletions(-)
diff --git a/addons/web/static/src/js/chrome/abstract_web_client.js b/addons/web/static/src/js/chrome/abstract_web_client.js
index 6b7df97b767..5adaaa36783 100644
--- a/addons/web/static/src/js/chrome/abstract_web_client.js
+++ b/addons/web/static/src/js/chrome/abstract_web_client.js
@@ -202,46 +202,6 @@ var AbstractWebClient = Widget.extend(ServiceProviderMixin, KeyboardNavigationMi
});
core.bus.on('connection_lost', this, this._onConnectionLost);
core.bus.on('connection_restored', this, this._onConnectionRestored);
-
- // crash manager integration
- core.bus.on('rpc_error', crash_manager, crash_manager.rpc_error);
- window.onerror = function (message, file, line, col, error) {
- // Scripts injected in DOM (eg: google API's js files) won't return a clean error on window.onerror.
- // The browser will just give you a 'Script error.' as message and nothing else for security issue.
- // To enable onerror to work properly with CORS file, you should:
- // 1. add crossorigin="anonymous" to your
+
@@ -247,7 +248,6 @@
-
diff --git a/odoo/http.py b/odoo/http.py
index 8702fd9a950..ab4512a6321 100644
--- a/odoo/http.py
+++ b/odoo/http.py
@@ -630,13 +630,18 @@ class JsonRequest(WebRequest):
try:
return super(JsonRequest, self)._handle_exception(exception)
except Exception:
- if not isinstance(exception, (odoo.exceptions.Warning, SessionExpiredException,
- odoo.exceptions.except_orm, werkzeug.exceptions.NotFound)):
- _logger.exception("Exception during JSON request handling.")
+ if not isinstance(exception, SessionExpiredException):
+ if exception.args and exception.args[0] == "bus.Bus not available in test mode":
+ _logger.info(exception)
+ elif isinstance(exception, (odoo.exceptions.Warning, odoo.exceptions.except_orm,
+ werkzeug.exceptions.NotFound)):
+ _logger.warning(exception)
+ else:
+ _logger.exception("Exception during JSON request handling.")
error = {
- 'code': 200,
- 'message': "Odoo Server Error",
- 'data': serialize_exception(exception)
+ 'code': 200,
+ 'message': "Odoo Server Error",
+ 'data': serialize_exception(exception),
}
if isinstance(exception, werkzeug.exceptions.NotFound):
error['http_status'] = 404
@@ -1414,7 +1419,7 @@ class Root(object):
httprequest = werkzeug.wrappers.Request(environ)
httprequest.app = self
httprequest.parameter_storage_class = werkzeug.datastructures.ImmutableOrderedMultiDict
-
+
current_thread = threading.current_thread()
current_thread.url = httprequest.url
current_thread.query_count = 0
From dc561aae036e03dbec9d4085ce2baaa9286f530b Mon Sep 17 00:00:00 2001
From: fja-odoo
Date: Tue, 11 Jun 2019 12:26:48 +0000
Subject: [PATCH 3/9] [IMP] website: enhance http error pages
- The traceback is only visible if in debug mode or if edit mode.
- All except_orm exceptions are now displayed as a 400
but the AccessError wich is a 403. There is now a dedicted page
for the 400 error.
- Errors messages are no longer the exception args but its name if the
exception is an except_orm. Else there is no message since the current
logic override exceptions of type Exception in ir_http thus we have
no message to display.
Part of https://github.com/odoo/odoo/pull/32132
task-1894820
---
addons/website/models/ir_http.py | 7 +++
addons/website/views/website_templates.xml | 64 ++++++++++++++--------
2 files changed, 48 insertions(+), 23 deletions(-)
diff --git a/addons/website/models/ir_http.py b/addons/website/models/ir_http.py
index e6eb9c10fa9..a00221596b4 100644
--- a/addons/website/models/ir_http.py
+++ b/addons/website/models/ir_http.py
@@ -214,6 +214,11 @@ class Http(models.AbstractModel):
traceback=traceback.format_exc(),
)
+ # only except_orm exceptions contain a message
+ if isinstance(exception, odoo.exceptions.except_orm):
+ values['error_message'] = exception.name
+ code = 400
+
if isinstance(exception, werkzeug.exceptions.HTTPException):
if exception.code is None:
# Hand-crafted HTTPException likely coming from abort(),
@@ -279,6 +284,8 @@ class Http(models.AbstractModel):
values['editable'] = request.uid and request.website.is_publisher()
elif code == 403:
logger.warn("403 Forbidden:\n\n%s", values['traceback'])
+ elif code == 400:
+ logger.warn("400 Bad Request:\n\n%s", values['traceback'])
try:
html = env['ir.ui.view'].render_template('website.%s' % view_id, values)
except Exception:
diff --git a/addons/website/views/website_templates.xml b/addons/website/views/website_templates.xml
index aa264dd76a7..c7d1b9fb19b 100644
--- a/addons/website/views/website_templates.xml
+++ b/addons/website/views/website_templates.xml
@@ -911,19 +911,22 @@
+
+
+ Error message:
+
+
+
+
-
+
-
+
-
The following error was raised in the website controller
-
- Error message:
-
-
+
@@ -931,7 +934,7 @@
-
+
Error message:
@@ -948,7 +951,7 @@
-
+
+
+
+
+
+
Oops! Something went wrong.
+
Take a look at the error message below.
+
+
+
+
+
+
+
+
+
+
+
+
+
-
403: Forbidden
+
403: Forbidden
The page you were looking for could not be authorized.
-
Maybe you were looking for one of these popular pages ?
-
-
-
-
+
+
+
+
+
+
+
+
@@ -982,7 +1004,7 @@
-
404: Page not found!
+
404: Page not found!
The page you were looking for could not be found; it is possible you have
typed the address incorrectly, but it has most probably been removed due
@@ -995,10 +1017,6 @@
-
-
-
-
From 83c1d56d2f3d22672803118f33c2f702721df1e5 Mon Sep 17 00:00:00 2001
From: fja-odoo
Date: Tue, 11 Jun 2019 12:26:50 +0000
Subject: [PATCH 4/9] [REF] mail, website, *: remove useless "in" classes
* website_sale_comparison
Just removing old "in" class from bootstrap3 wich has been replaced by
"show" in bootstrap4.
Part of https://github.com/odoo/odoo/pull/32132
task-1894820
---
addons/mail/static/src/xml/activity.xml | 2 +-
addons/website/views/website_templates.xml | 2 +-
.../views/website_sale_comparison_template.xml | 4 ++--
3 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/addons/mail/static/src/xml/activity.xml b/addons/mail/static/src/xml/activity.xml
index 217e1a39f5c..11b4b0e9022 100644
--- a/addons/mail/static/src/xml/activity.xml
+++ b/addons/mail/static/src/xml/activity.xml
@@ -12,7 +12,7 @@
-