From ab4000fb3cf8fa54ba714ceceec391b78d73755e Mon Sep 17 00:00:00 2001 From: Julien Castiaux Date: Wed, 19 Feb 2020 13:34:27 +0000 Subject: [PATCH] [REF] base: Remove deprecated exceptions and osv TL;DR: remember `osv` and `except_orm` ? You can forget about them. * Deprecated `except_orm` dropped. * `UserError` elevated as super type of all user-related errors. * Unused `DeferredException` dropped. * Unused `QWebException` dropped (real one is in `qweb.py`). * `MailDeliveryException` made a python exception. * `name` legacy exception attribute made an alias of the python standard `args[0]` attribute and deprecated. * `value` legacy exception attribute dropped. * `exception_type` RPC error response key dropped. * Deprecated `osv` module dropped. * `--osv-memory-age-limit` cli option made an alias of `--transient-age-limit` and deprecated. The `odoo.exceptions.Warning` have long been a deprecated alias to `UserError`. It is going to be removed in a future version but first we explicitly deprecate it with a warning. The `odoo.exceptions.DeferredException` was a very old internal exception, it has been removed without deprecation notice as it is never raised. The `odoo.exceptions.except_orm` has been a deprecated exception type with deprecation warning for 5 years, it has been removed in favor of UserError which becomes the super class of all user-related errors. The `odoo.base.models.ir_mail_server.MailDeliveryException` was inheriting `except_orm`. As it is not related to a user error but is more of a problem an admin much take care of, the exception has been made a Python error. The `exception_type` JSON key in RPC error responses was holding an hardcoded value derived from the exception type. Its usage has been dropped in favor of the `name` JSON key that holds the precise exception name. Again as it was hardly used in the source code (beside the crash manager) it has been dropped without deprecation warning. Since we are here trying to clean odoo custom exceptions, we are also deprecating the `name` exception attribute in favor of the more standard `args[0]` attribute. The `name` (along with `value`) were two attributes used to raise `except_orm` exceptions before the introduction of `UserError`, `AccessError` and related exceptions. The `name` attribute, at the time, was holding the exception type/title. Nowadays it contains the error message. The `value` attribute, at the time, was holding the error message. Nowadays it is no more used. The `osv` module contains very old deprecated aliases. There is no simple way to log a deprecation warning for osv, osv_memory and osv_abstract but as they have not been in use for ages, they have been removed too. To be consistent, the `--osv-memory-age-limit` cli option has been made a deprecated alias to the `--transient-age-limit`. closes odoo/odoo#45723 Task: 2187728 Related: odoo/enterprise#9162 Signed-off-by: Raphael Collet (rco) --- addons/account_facturx/models/account_move.py | 4 +- addons/auth_signup/controllers/main.py | 4 +- addons/delivery/models/delivery_grid.py | 2 +- addons/http_routing/models/ir_http.py | 5 +- addons/mail/models/mail_mail.py | 4 +- addons/mail/wizard/mail_template_preview.py | 2 +- addons/mrp/tests/test_stock.py | 4 +- addons/payment_authorize/controllers/main.py | 2 +- addons/point_of_sale/static/src/js/models.js | 12 --- addons/test_mail/tests/test_mail_channel.py | 10 +- addons/test_mail/tests/test_mail_message.py | 18 ++-- addons/web/controllers/main.py | 4 +- .../static/src/js/services/crash_manager.js | 78 +++++--------- .../tests/chrome/action_manager_tests.js | 1 - addons/web_editor/static/src/js/editor/rte.js | 2 +- addons/website/models/ir_http.py | 2 +- addons/website_slides/controllers/main.py | 12 +-- odoo/addons/base/models/ir_actions.py | 1 + odoo/addons/base/models/ir_mail_server.py | 7 +- odoo/addons/base/tests/test_ir_filters.py | 4 +- odoo/addons/base/tests/test_res_config.py | 2 +- odoo/addons/test_exceptions/models.py | 21 ---- odoo/addons/test_exceptions/view.xml | 24 ----- .../test_new_api/tests/test_new_fields.py | 2 +- odoo/exceptions.py | 100 +++++++----------- odoo/http.py | 29 +---- odoo/models.py | 2 +- odoo/osv/__init__.py | 1 - odoo/osv/osv.py | 14 --- odoo/service/model.py | 10 +- odoo/service/wsgi_server.py | 26 ++--- odoo/tools/config.py | 27 +++-- odoo/tools/safe_eval.py | 10 +- odoo/tools/test-config-values-00.conf | 2 +- odoo/tools/test_config.py | 12 +-- 35 files changed, 148 insertions(+), 312 deletions(-) delete mode 100644 odoo/osv/osv.py diff --git a/addons/account_facturx/models/account_move.py b/addons/account_facturx/models/account_move.py index 68020ea6c90..92d3f6c225c 100644 --- a/addons/account_facturx/models/account_move.py +++ b/addons/account_facturx/models/account_move.py @@ -3,7 +3,7 @@ from odoo import api, models, fields, tools, _ from odoo.tools import DEFAULT_SERVER_DATE_FORMAT, float_repr from odoo.tests.common import Form -from odoo.exceptions import UserError, except_orm +from odoo.exceptions import UserError from datetime import datetime from lxml import etree @@ -271,7 +271,7 @@ class AccountMove(models.Model): self._import_facturx_invoice(tree) self._remove_ocr_option() buffer.close() - except except_orm as e: + except UserError as e: raise e except Exception as e: # Malformed pdf diff --git a/addons/auth_signup/controllers/main.py b/addons/auth_signup/controllers/main.py index 6fc0c58f919..82219be6930 100644 --- a/addons/auth_signup/controllers/main.py +++ b/addons/auth_signup/controllers/main.py @@ -46,7 +46,7 @@ class AuthSignupHome(Home): template.sudo().send_mail(user_sudo.id, force_send=True) return self.web_login(*args, **kw) except UserError as e: - qcontext['error'] = e.name or e.value + qcontext['error'] = e.args[0] except (SignupError, AssertionError) as e: if request.env["res.users"].sudo().search([("login", "=", qcontext.get("login"))]): qcontext["error"] = _("Another user is already registered using this email address.") @@ -79,7 +79,7 @@ class AuthSignupHome(Home): request.env['res.users'].sudo().reset_password(login) qcontext['message'] = _("An email has been sent with credentials to reset your password") except UserError as e: - qcontext['error'] = e.name or e.value + qcontext['error'] = e.args[0] except SignupError: qcontext['error'] = _("Could not reset your password") _logger.exception('error when resetting password') diff --git a/addons/delivery/models/delivery_grid.py b/addons/delivery/models/delivery_grid.py index 5cef40ac210..17bc32a4f3b 100644 --- a/addons/delivery/models/delivery_grid.py +++ b/addons/delivery/models/delivery_grid.py @@ -58,7 +58,7 @@ class ProviderGrid(models.Model): except UserError as e: return {'success': False, 'price': 0.0, - 'error_message': e.name, + 'error_message': e.args[0], 'warning_message': False} if order.company_id.currency_id.id != order.pricelist_id.currency_id.id: price_unit = order.company_id.currency_id._convert( diff --git a/addons/http_routing/models/ir_http.py b/addons/http_routing/models/ir_http.py index c0fd4a46a19..064665d5d15 100644 --- a/addons/http_routing/models/ir_http.py +++ b/addons/http_routing/models/ir_http.py @@ -572,9 +572,8 @@ class IrHttp(models.AbstractModel): exception=exception, traceback=traceback.format_exc(), ) - # only except_orm exceptions contain a message - if isinstance(exception, exceptions.except_orm): - values['error_message'] = exception.name + if isinstance(exception, exceptions.UserError): + values['error_message'] = exception.args[0] code = 400 if isinstance(exception, exceptions.AccessError): code = 403 diff --git a/addons/mail/models/mail_mail.py b/addons/mail/models/mail_mail.py index 598c92d999f..49abe210f7a 100644 --- a/addons/mail/models/mail_mail.py +++ b/addons/mail/models/mail_mail.py @@ -416,10 +416,8 @@ class MailMail(models.Model): if isinstance(e, UnicodeEncodeError): value = "Invalid text: %s" % e.object else: - # get the args of the original error, wrap into a value and throw a MailDeliveryException - # that is an except_orm, with name and value as arguments value = '. '.join(e.args) - raise MailDeliveryException(_("Mail Delivery Failed"), value) + raise MailDeliveryException(value) raise if auto_commit is True: diff --git a/addons/mail/wizard/mail_template_preview.py b/addons/mail/wizard/mail_template_preview.py index 7cedde9b5e5..03062beee74 100644 --- a/addons/mail/wizard/mail_template_preview.py +++ b/addons/mail/wizard/mail_template_preview.py @@ -73,7 +73,7 @@ class MailTemplatePreview(models.TransientModel): self.error_msg = False except UserError as user_error: self._set_mail_attributes() - self.error_msg = user_error.name + self.error_msg = user_error.args[0] finally: # Avoid to be change by a invalidate_cache call (in generate_mail), e.g. Quotation / Order report for key, value in copy_depends_values.items(): diff --git a/addons/mrp/tests/test_stock.py b/addons/mrp/tests/test_stock.py index 2c03f3234c1..f2c012737c7 100644 --- a/addons/mrp/tests/test_stock.py +++ b/addons/mrp/tests/test_stock.py @@ -2,7 +2,7 @@ # Part of Odoo. See LICENSE file for full copyright and licensing details. from . import common -from odoo.exceptions import except_orm +from odoo.exceptions import UserError from odoo.tests import Form @@ -150,7 +150,7 @@ class TestWarehouse(common.TestMrpCommon): # Scrap Product Wood without lot to check assert raise ?. scrap_id = self.env['stock.scrap'].with_context(active_model='mrp.production', active_id=production_3.id).create({'product_id': self.product_2.id, 'scrap_qty': 1.0, 'product_uom_id': self.product_2.uom_id.id, 'location_id': location_id, 'production_id': production_3.id}) - with self.assertRaises(except_orm): + with self.assertRaises(UserError): scrap_id.do_scrap() # Scrap Product Wood with lot. diff --git a/addons/payment_authorize/controllers/main.py b/addons/payment_authorize/controllers/main.py index 49f919f4198..4417f0408bb 100644 --- a/addons/payment_authorize/controllers/main.py +++ b/addons/payment_authorize/controllers/main.py @@ -57,7 +57,7 @@ class AuthorizeController(http.Controller): } except UserError as e: return { - 'error': e.name, + 'error': e.args[0], } if not token: diff --git a/addons/point_of_sale/static/src/js/models.js b/addons/point_of_sale/static/src/js/models.js index 12c488793d0..a318641fe92 100644 --- a/addons/point_of_sale/static/src/js/models.js +++ b/addons/point_of_sale/static/src/js/models.js @@ -1022,11 +1022,6 @@ exports.PosModel = Backbone.Model.extend({ }).catch(function (reason){ var error = reason.message; if(error.code === 200 ){ // Business Logic Error, not a connection problem - //if warning do not need to display traceback!! - if (error.data.exception_type == 'warning') { - delete error.data.debug; - } - // Hide error if already shown before ... if ((!self.get('failed') || options.show_error) && !options.to_invoice) { self.gui.show_popup('error-traceback',{ @@ -1071,13 +1066,6 @@ exports.PosModel = Backbone.Model.extend({ self.db.set_ids_removed_from_server(server_ids); return server_ids; }).catch(function (reason){ - var error = reason.message; - if(error.code === 200 ){ // Business Logic Error, not a connection problem - //if warning do not need to display traceback!! - if (error.data.exception_type == 'warning') { - delete error.data.debug; - } - } self.gui.show_sync_error_popup(); console.error('Failed to remove orders:', server_ids); }); diff --git a/addons/test_mail/tests/test_mail_channel.py b/addons/test_mail/tests/test_mail_channel.py index 3fb07f010ce..cb9d949c7ef 100644 --- a/addons/test_mail/tests/test_mail_channel.py +++ b/addons/test_mail/tests/test_mail_channel.py @@ -4,7 +4,7 @@ from odoo.tests import tagged from odoo.addons.mail.tests.common import mail_new_test_user from odoo.addons.test_mail.tests.common import TestMailCommon -from odoo.exceptions import AccessError, except_orm, ValidationError, UserError +from odoo.exceptions import AccessError, ValidationError, UserError from odoo.tools import mute_logger, formataddr @@ -39,10 +39,7 @@ class TestChannelAccessRights(TestMailCommon): self.group_public.with_user(self.user_public).read() # Read Pigs -> ko, restricted to employees - # TODO: Change the except_orm to Warning ( Because here it's call check_access_rule - # which still generate exception in except_orm.So we need to change all - # except_orm to warning in mail module.) - with self.assertRaises(except_orm): + with self.assertRaises(AccessError): self.group_pigs.with_user(self.user_public).read() # Read a private group when being a member: ok @@ -64,7 +61,6 @@ class TestChannelAccessRights(TestMailCommon): @mute_logger('odoo.addons.base.models.ir_model', 'odoo.models', 'odoo.models.unlink') def test_access_rights_groups(self): # Employee read employee-based group: ok - # TODO Change the except_orm to Warning self.group_pigs.with_user(self.user_employee).read() # Employee can create a group @@ -77,7 +73,7 @@ class TestChannelAccessRights(TestMailCommon): self.group_pigs.with_user(self.user_employee).unlink() # Employee cannot read a private group - with self.assertRaises(except_orm): + with self.assertRaises(AccessError): self.group_private.with_user(self.user_employee).read() # Employee cannot write on private diff --git a/addons/test_mail/tests/test_mail_message.py b/addons/test_mail/tests/test_mail_message.py index 1487597f56a..42c48aa960f 100644 --- a/addons/test_mail/tests/test_mail_message.py +++ b/addons/test_mail/tests/test_mail_message.py @@ -7,7 +7,7 @@ from unittest.mock import patch from odoo.addons.mail.tests.common import mail_new_test_user from odoo.addons.test_mail.tests.common import TestMailCommon from odoo.addons.test_mail.models.test_mail_models import MailTestSimple -from odoo.exceptions import AccessError, except_orm +from odoo.exceptions import AccessError from odoo.tools import mute_logger, formataddr from odoo.tests import tagged @@ -244,15 +244,12 @@ class TestMessageAccess(TestMailCommon): @mute_logger('odoo.addons.base.models.ir_model', 'odoo.models') def test_mail_message_access_read_crash(self): - # TODO: Change the except_orm to Warning ( Because here it's call check_access_rule - # which still generate exception in except_orm.So we need to change all - # except_orm to warning in mail module.) - with self.assertRaises(except_orm): + with self.assertRaises(AccessError): self.message.with_user(self.user_employee).read() @mute_logger('odoo.models') def test_mail_message_access_read_crash_portal(self): - with self.assertRaises(except_orm): + with self.assertRaises(AccessError): self.message.with_user(self.user_portal).read(['body', 'message_type', 'subtype_id']) def test_mail_message_access_read_ok_portal(self): @@ -302,17 +299,16 @@ class TestMessageAccess(TestMailCommon): @mute_logger('odoo.models') def test_mail_message_access_create_crash(self): # Do: Bert create a private message -> ko, no creation rights - with self.assertRaises(except_orm): + with self.assertRaises(AccessError): self.env['mail.message'].with_user(self.user_employee).create({'model': 'mail.channel', 'res_id': self.group_private.id, 'body': 'Test'}) @mute_logger('odoo.models') def test_mail_message_access_create_doc(self): - # TODO Change the except_orm to Warning Message = self.env['mail.message'].with_user(self.user_employee) # Do: Raoul creates a message on Jobs -> ok, write access to the related document Message.create({'model': 'mail.channel', 'res_id': self.group_public.id, 'body': 'Test'}) # Do: Raoul creates a message on Priv -> ko, no write access to the related document - with self.assertRaises(except_orm): + with self.assertRaises(AccessError): Message.create({'model': 'mail.channel', 'res_id': self.group_private.id, 'body': 'Test'}) def test_mail_message_access_create_private(self): @@ -338,11 +334,11 @@ class TestMessageAccess(TestMailCommon): body='

This is First Message

', subject='Subject', message_type='comment', subtype_xmlid='mail.mt_note') # portal user have no rights to read the message - with self.assertRaises(except_orm): + with self.assertRaises(AccessError): message.with_user(self.user_portal).read(['subject, body']) with patch.object(MailTestSimple, 'check_access_rights', return_value=True): - with self.assertRaises(except_orm): + with self.assertRaises(AccessError): message.with_user(self.user_portal).read(['subject, body']) # parent message is accessible to references notification mail values diff --git a/addons/web/controllers/main.py b/addons/web/controllers/main.py index b450663cd46..c68966af4bc 100644 --- a/addons/web/controllers/main.py +++ b/addons/web/controllers/main.py @@ -1198,12 +1198,12 @@ class Session(http.Controller): try: if request.env['res.users'].change_password(old_password, new_password): return {'new_password':new_password} - except UserError as e: - msg = e.name except AccessDenied as e: msg = e.args[0] if msg == AccessDenied().args[0]: msg = _('The old password you provided is incorrect, your password was not changed.') + except UserError as e: + msg = e.args[0] return {'title': _('Change Password'), 'error': msg} @http.route('/web/session/get_lang_list', type='json', auth="none") diff --git a/addons/web/static/src/js/services/crash_manager.js b/addons/web/static/src/js/services/crash_manager.js index 19db73e1da5..b653aaa1c8d 100644 --- a/addons/web/static/src/js/services/crash_manager.js +++ b/addons/web/static/src/js/services/crash_manager.js @@ -87,6 +87,13 @@ var CrashManager = AbstractService.extend({ var self = this; active = true; this.isConnected = true; + this.odooExceptionTitleMap = { + 'odoo.exceptions.AccessDenied': _lt("Access Denied"), + 'odoo.exceptions.AccessError': _lt("Access Error"), + 'odoo.exceptions.MissingError': _lt("Missing Record"), + 'odoo.exceptions.UserError': _lt("User Error"), + 'odoo.exceptions.ValidationError': _lt("Validation Error"), + }; this._super.apply(this, arguments); @@ -180,70 +187,35 @@ var CrashManager = AbstractService.extend({ rpc_error: function(error) { // Some qunit tests produces errors before the DOM is set. // This produces an error loop as the modal/toast has no DOM to attach to. - if (!document.body) { - return; - } - var map_title = { - access_denied: _lt("Access Denied"), - access_error: _lt("Access Error"), - except_orm: _lt("Global Business Error"), - missing_error: _lt("Missing Record"), - user_error: _lt("User Error"), - validation_error: _lt("Validation Error"), - warning: _lt("Warning"), - }; - if (!active) { - return; - } - if (this.connection_lost) { - return; - } + if (!document.body || !active || this.connection_lost) return; + + // Connection lost error if (error.code === -32098) { this.handleLostConnection(); return; } + + // Special exception handlers, see crash_registry bellow var handler = core.crash_registry.get(error.data.name, true); if (handler) { new (handler)(this, error).display(); return; } - if (_.has(map_title, error.data.exception_type)) { - if (error.data.exception_type === 'except_orm') { - if (error.data.arguments[1]) { - error = _.extend({}, error, - { - data: _.extend({}, error.data, - { - message: error.data.arguments[1], - title: error.data.arguments[0] !== 'Warning' ? error.data.arguments[0] : '', - }) - }); - } - else { - error = _.extend({}, error, - { - data: _.extend({}, error.data, - { - message: error.data.arguments[0], - title: '', - }) - }); - } - } - else { - error = _.extend({}, error, - { - data: _.extend({}, error.data, - { - message: error.data.arguments[0], - title: map_title[error.data.exception_type] !== 'Warning' ? map_title[error.data.exception_type] : '', - }) - }); - } + + // Odoo custom exception: UserError, AccessError, ... + if (_.has(this.odooExceptionTitleMap, error.data.name)) { + error = _.extend({}, error, { + data: _.extend({}, error.data, { + message: error.data.arguments[0], + title: this.odooExceptionTitleMap[error.data.name], + }), + }); this.show_warning(error); - } else { - this.show_error(error); + return; } + + // Any other Python exception + this.show_error(error); }, show_warning: function (error, options) { if (!active) { diff --git a/addons/web/static/tests/chrome/action_manager_tests.js b/addons/web/static/tests/chrome/action_manager_tests.js index 5af731abf81..96835f8eab5 100644 --- a/addons/web/static/tests/chrome/action_manager_tests.js +++ b/addons/web/static/tests/chrome/action_manager_tests.js @@ -2277,7 +2277,6 @@ QUnit.module('ActionManager', { params.error({ data: { name: 'error', - exception_type: 'warning', arguments: ['could not download file'], } }); diff --git a/addons/web_editor/static/src/js/editor/rte.js b/addons/web_editor/static/src/js/editor/rte.js index cbce901c48d..feb28100854 100644 --- a/addons/web_editor/static/src/js/editor/rte.js +++ b/addons/web_editor/static/src/js/editor/rte.js @@ -510,7 +510,7 @@ var RTEWidget = Widget.extend({ // new rejection with all relevant info var id = _.uniqueId('carlos_danger_'); $el.addClass('o_dirty oe_carlos_danger ' + id); - var html = (response.message.data.exception_type === 'except_osv'); + var html = Boolean(response.data.name); if (html) { var msg = $('
', {text: response.message.data.message}).html(); var data = msg.substring(3, msg.length -2).split(/', u'/); diff --git a/addons/website/models/ir_http.py b/addons/website/models/ir_http.py index ae68a21e174..2e6aa532f88 100644 --- a/addons/website/models/ir_http.py +++ b/addons/website/models/ir_http.py @@ -299,7 +299,7 @@ class Http(models.AbstractModel): try: # exception.name might be int, string exception_template = int(exception.name) - except: + except ValueError: exception_template = exception.name view = View._view_obj(exception_template) if exception.html and exception.html in view.arch: diff --git a/addons/website_slides/controllers/main.py b/addons/website_slides/controllers/main.py index 8691313dc88..25d53bce316 100644 --- a/addons/website_slides/controllers/main.py +++ b/addons/website_slides/controllers/main.py @@ -602,9 +602,9 @@ class WebsiteSlides(WebsiteProfile): channel = request.env['slide.channel'].browse(int(channel_id)) can_upload = channel.can_upload can_publish = channel.can_publish - except (UserError, AccessError) as e: + except UserError as e: _logger.error(e) - return {'error': e.name} + return {'error': e.args[0]} else: if not can_upload or not can_publish: return {'error': _('You cannot add tags to this course.')} @@ -1013,9 +1013,9 @@ class WebsiteSlides(WebsiteProfile): channel = request.env['slide.channel'].browse(values['channel_id']) can_upload = channel.can_upload can_publish = channel.can_publish - except (UserError, AccessError) as e: + except UserError as e: _logger.error(e) - return {'error': e.name} + return {'error': e.args[0]} else: if not can_upload: return {'error': _('You cannot upload on this channel.')} @@ -1042,9 +1042,9 @@ class WebsiteSlides(WebsiteProfile): values['user_id'] = request.env.uid values['is_published'] = values.get('is_published', False) and can_publish slide = request.env['slide.slide'].sudo().create(values) - except (UserError, AccessError) as e: + except UserError as e: _logger.error(e) - return {'error': e.name} + return {'error': e.args[0]} except Exception as e: _logger.error(e) return {'error': _('Internal server error, please try again later or contact administrator.\nHere is the error message: %s') % e} diff --git a/odoo/addons/base/models/ir_actions.py b/odoo/addons/base/models/ir_actions.py index a3c7c4857ca..5d207e80591 100644 --- a/odoo/addons/base/models/ir_actions.py +++ b/odoo/addons/base/models/ir_actions.py @@ -508,6 +508,7 @@ class IrActionsServer(models.Model): 'model': model, # Exceptions 'Warning': odoo.exceptions.Warning, + 'UserError': odoo.exceptions.UserError, # record 'record': record, 'records': records, diff --git a/odoo/addons/base/models/ir_mail_server.py b/odoo/addons/base/models/ir_mail_server.py index 8c5399236c7..8d0bf2a21f1 100644 --- a/odoo/addons/base/models/ir_mail_server.py +++ b/odoo/addons/base/models/ir_mail_server.py @@ -15,7 +15,7 @@ import threading import html2text from odoo import api, fields, models, tools, _ -from odoo.exceptions import except_orm, UserError +from odoo.exceptions import UserError from odoo.tools import ustr, pycompat _logger = logging.getLogger(__name__) @@ -24,10 +24,9 @@ _test_logger = logging.getLogger('odoo.tests') SMTP_TIMEOUT = 60 -class MailDeliveryException(except_orm): +class MailDeliveryException(Exception): """Specific exception subclass for mail delivery errors""" - def __init__(self, name, value): - super(MailDeliveryException, self).__init__(name, value) + # Python 3: patch SMTP's internal printer/debugger def _print_debug(self, *args): diff --git a/odoo/addons/base/tests/test_ir_filters.py b/odoo/addons/base/tests/test_ir_filters.py index cb4b39ff8e2..59c4a39c608 100644 --- a/odoo/addons/base/tests/test_ir_filters.py +++ b/odoo/addons/base/tests/test_ir_filters.py @@ -222,7 +222,7 @@ class TestGlobalDefaults(FiltersCase): ) Filters = self.env['ir.filters'].with_user(self.USER_ID) - with self.assertRaises(exceptions.Warning): + with self.assertRaises(exceptions.UserError): Filters.create_or_replace({ 'name': 'c', 'model_id': 'ir.filters', @@ -242,7 +242,7 @@ class TestGlobalDefaults(FiltersCase): ) Filters = self.env['ir.filters'].with_user(self.USER_ID) - with self.assertRaises(exceptions.Warning): + with self.assertRaises(exceptions.UserError): Filters.create_or_replace({ 'name': 'a', 'model_id': 'ir.filters', diff --git a/odoo/addons/base/tests/test_res_config.py b/odoo/addons/base/tests/test_res_config.py index 70d1aed99b8..552d8759715 100644 --- a/odoo/addons/base/tests/test_res_config.py +++ b/odoo/addons/base/tests/test_res_config.py @@ -78,7 +78,7 @@ class TestResConfig(TransactionCase): res = self.ResConfig.get_config_warning(self.error_msg_wo_menu) # Check type - self.assertIsInstance(res, exceptions.Warning) + self.assertIsInstance(res, exceptions.UserError) # Check returned value self.assertEqual(res.args[0], self.expected_final_error_msg_wo_menu) diff --git a/odoo/addons/test_exceptions/models.py b/odoo/addons/test_exceptions/models.py index 7028ddda128..cb218aaac32 100644 --- a/odoo/addons/test_exceptions/models.py +++ b/odoo/addons/test_exceptions/models.py @@ -2,7 +2,6 @@ # Part of Odoo. See LICENSE file for full copyright and licensing details. import odoo.exceptions -import odoo.osv.osv from odoo import models, api from odoo.tools.safe_eval import safe_eval @@ -14,17 +13,6 @@ class m(models.Model): _name = 'test.exceptions.model' _description = 'Test Exception Model' - def generate_except_osv(self): - # title is ignored in the new (6.1) exceptions - raise odoo.osv.osv.except_osv('title', 'description') - - def generate_except_orm(self): - # title is ignored in the new (6.1) exceptions - raise odoo.exceptions.except_orm('title', 'description') - - def generate_warning(self): - raise odoo.exceptions.Warning('description') - def generate_redirect_warning(self): action = self.env.ref('test_exceptions.action_test_exceptions') raise odoo.exceptions.RedirectWarning('description', action.id, 'Go to the redirection') @@ -50,15 +38,6 @@ class m(models.Model): def generate_validation_error(self): raise odoo.exceptions.ValidationError('description') - def generate_except_osv_safe_eval(self): - self.generate_safe_eval(self.generate_except_osv) - - def generate_except_orm_safe_eval(self): - self.generate_safe_eval(self.generate_except_orm) - - def generate_warning_safe_eval(self): - self.generate_safe_eval(self.generate_warning) - def generate_redirect_warning_safe_eval(self): self.generate_safe_eval(self.generate_redirect_warning) diff --git a/odoo/addons/test_exceptions/view.xml b/odoo/addons/test_exceptions/view.xml index 0e8f96a7c91..30f19e19b58 100644 --- a/odoo/addons/test_exceptions/view.xml +++ b/odoo/addons/test_exceptions/view.xml @@ -10,18 +10,6 @@

Each button generates a specific exception on the server. The text on the right is the expected representation of the exception when displayed on the client. Button marked with a '*' use safe_eval().

-
-
-
-
-
-
-
-
-
-
-
-