summaryrefslogtreecommitdiff
path: root/odoo
diff options
context:
space:
mode:
authorChristophe Simonis <chs@odoo.com>2018-02-01 16:40:13 +0100
committerChristophe Simonis <chs@odoo.com>2018-02-01 16:40:13 +0100
commit920aa6174c938bbfc0864a95ff3d8ebbe3132387 (patch)
treea1bd8f8871cba6af086607d94842a4f5e53fbbbe /odoo
parenteeebd4ad857fec39c14abc0a0e387c13adcfa30b (diff)
parente0422bfd6c528313ee399dad3e67407360d49725 (diff)
[MERGE] forward port branch saas-15 up to e0422bfd6c5
Diffstat (limited to 'odoo')
-rw-r--r--odoo/http.py12
1 files changed, 9 insertions, 3 deletions
diff --git a/odoo/http.py b/odoo/http.py
index 8f9c5932f0f..946e915ce29 100644
--- a/odoo/http.py
+++ b/odoo/http.py
@@ -637,8 +637,9 @@ class JsonRequest(WebRequest):
body = json.dumps(response, default=ustr)
return Response(
- body, headers=[('Content-Type', mime),
- ('Content-Length', len(body))])
+ body, status=error and error.pop('http_status', 200) or 200,
+ headers=[('Content-Type', mime), ('Content-Length', len(body))]
+ )
def _handle_exception(self, exception):
"""Called within an except block to allow converting exceptions
@@ -647,13 +648,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)):
+ if not isinstance(exception, (odoo.exceptions.Warning, SessionExpiredException,
+ odoo.exceptions.except_orm, werkzeug.exceptions.NotFound)):
_logger.exception("Exception during JSON request handling.")
error = {
'code': 200,
'message': "Odoo Server Error",
'data': serialize_exception(exception)
}
+ if isinstance(exception, werkzeug.exceptions.NotFound):
+ error['http_status'] = 404
+ error['code'] = 404
+ error['message'] = "404: Not Found"
if isinstance(exception, AuthenticationError):
error['code'] = 100
error['message'] = "Odoo Session Invalid"