From 0d1407a715901ea06e9a7211c0e3dbe09fadb785 Mon Sep 17 00:00:00 2001 From: fja-odoo Date: Tue, 11 Jun 2019 12:26:55 +0000 Subject: [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 --- addons/test_website/__manifest__.py | 1 + addons/test_website/controllers/main.py | 9 ++++++++ .../test_website/static/tests/tours/error_views.js | 25 ++++++++++++++++++++++ 3 files changed, 35 insertions(+) (limited to 'addons/test_website') 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 @@ -44,6 +44,13 @@ tour.register('test_error_website', { content: "rpc error 403 modal has message", 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"]', @@ -131,6 +138,24 @@ tour.register('test_error_website', { run: function () { 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")', -- cgit v1.2.3