diff options
| author | Christophe Simonis <chs@odoo.com> | 2018-02-01 14:16:50 +0100 |
|---|---|---|
| committer | Christophe Simonis <chs@odoo.com> | 2018-02-01 14:16:50 +0100 |
| commit | 7d465aa56cf421d009b25a41fc226f82de7c2192 (patch) | |
| tree | 6838248a00d58299b31fee243109ceada8ec0b77 /odoo | |
| parent | 5b230c34cb960f3f729d6612735dd9c3c896b785 (diff) | |
| parent | 4c9bf7faae4e5e53955fde1e69ef82e72dd51ccb (diff) | |
[MERGE] forward port branch 10.0 up to 4c9bf7faae4
Diffstat (limited to 'odoo')
| -rw-r--r-- | odoo/http.py | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/odoo/http.py b/odoo/http.py index 56b1f8e6930..780521db857 100644 --- a/odoo/http.py +++ b/odoo/http.py @@ -629,8 +629,9 @@ class JsonRequest(WebRequest): body = json.dumps(response) 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 @@ -639,13 +640,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" |
