diff options
| author | fja-odoo <fja@odoo.com> | 2019-06-11 12:26:55 +0000 |
|---|---|---|
| committer | fja-odoo <fja@odoo.com> | 2019-06-28 08:53:53 +0000 |
| commit | 0d1407a715901ea06e9a7211c0e3dbe09fadb785 (patch) | |
| tree | d7d3a6cf49a358298b8caa2da8cd025be017c309 /addons/test_website | |
| parent | 90818fd083774988c331d741d34181a5af5ecd3a (diff) | |
[IMP] base, web, *: make KarmaError an except_orm
* = gamification, test_website, stock
- KarmaError is now handled as a 400 exception.
- test_website has been updated.
- NO_POSTMORTEM is now clean it was referencing duplicates as most the
exceptions inherit from except_orm.
- serialize_exception from http.py has been moved to ir_http
to take advantage of the odoo inheritance system. We can then
extend ir_http serialize_exception method to add the KarmaError
logic if and only if gamification is installed.
Places where serialize_exception was previously used are updated.
Part of https://github.com/odoo/odoo/pull/32132
task-1894820
Diffstat (limited to 'addons/test_website')
| -rw-r--r-- | addons/test_website/__manifest__.py | 1 | ||||
| -rw-r--r-- | addons/test_website/controllers/main.py | 9 | ||||
| -rw-r--r-- | addons/test_website/static/tests/tours/error_views.js | 25 |
3 files changed, 35 insertions, 0 deletions
diff --git a/addons/test_website/__manifest__.py b/addons/test_website/__manifest__.py index 557722971d4..e1bac638412 100644 --- a/addons/test_website/__manifest__.py +++ b/addons/test_website/__manifest__.py @@ -14,6 +14,7 @@ dependencies. Neither we want to add in website module some routes, views and models which only purpose is to run tests.""", 'depends': [ 'website', + 'gamification', ], 'data': [ 'views/templates.xml', diff --git a/addons/test_website/controllers/main.py b/addons/test_website/controllers/main.py index cc60ccfd25f..0a8210881c7 100644 --- a/addons/test_website/controllers/main.py +++ b/addons/test_website/controllers/main.py @@ -8,6 +8,7 @@ from odoo import http from odoo.http import request from odoo.addons.portal.controllers.web import Home from odoo.exceptions import UserError, ValidationError, AccessError, MissingError, AccessError, AccessDenied +from odoo.addons.gamification.models.gamification_karma_rank import KarmaError class WebsiteTest(Home): @@ -80,6 +81,14 @@ class WebsiteTest(Home): def test_missing_error_http(self, **kwargs): raise MissingError("This is a missing http test") + @http.route('/test_karma_error_json', type='json', auth='public', website=True) + def test_karma_error_rpc(self, **kwargs): + raise KarmaError("This is a karma rpc test") + + @http.route('/test_karma_error_http', type='http', auth='public', website=True) + def test_karma_error_http(self, **kwargs): + raise KarmaError("This is a karma http test") + @http.route('/test_internal_error_json', type='json', auth='public', website=True) def test_internal_error_json(self, **kwargs): raise werkzeug.exceptions.InternalServerError() diff --git a/addons/test_website/static/tests/tours/error_views.js b/addons/test_website/static/tests/tours/error_views.js index a3d9f3fa035..f76ba28ff8e 100644 --- a/addons/test_website/static/tests/tours/error_views.js +++ b/addons/test_website/static/tests/tours/error_views.js @@ -45,6 +45,13 @@ tour.register('test_error_website', { extra_trigger: 'div.o_dialog_warning.modal-body:contains("This is an access denied rpc test")', trigger: 'button.btn.btn-primary', }, { + content: "trigger rpc missing error", + trigger: 'a[href="/test_karma_error_json"]', + }, { + content: "rpc missing error modal has message", + extra_trigger: 'div.o_dialog_warning.modal-body:contains("This is a karma rpc test")', + trigger: 'button.btn.btn-primary', + }, { content: "trigger rpc error 500", trigger: 'a[href="/test_internal_error_json"]', }, { @@ -132,6 +139,24 @@ tour.register('test_error_website', { window.location.href = window.location.origin + '/test_karma_error_http?debug=0'; }, }, { + content: "http karma error page has title and message", + extra_trigger: 'h1:contains("Oops! Something went wrong.")', + trigger: 'div.container pre:contains("This is a karma http test")', + run: function () { + window.location.href = window.location.origin + '/test_karma_error_http?debug=1'; + }, + }, { + content: "http karma error page debug has title and message open", + extra_trigger: 'h1:contains("Oops! Something went wrong.")', + trigger: 'div#error_main.collapse.show pre:contains("This is a karma http test")', + run: function () {}, + }, { + content: "http karma error page debug has traceback closed", + trigger: 'body:has(div#error_traceback.collapse:not(.show) pre#exception_traceback)', + run: function () { + window.location.href = window.location.origin + '/test_access_denied_http?debug=0'; + }, + }, { content: "http error 403 page has title but no message", extra_trigger: 'h1:contains("403: Forbidden")', trigger: 'div#wrap:not(:has(pre:contains("This is an access denied http test"))', //See ir_http.py handle_exception, the exception is replaced so there is no message ! |
