summaryrefslogtreecommitdiff
path: root/addons
diff options
context:
space:
mode:
Diffstat (limited to 'addons')
-rw-r--r--addons/account_facturx/models/account_move.py4
-rw-r--r--addons/auth_signup/controllers/main.py4
-rw-r--r--addons/delivery/models/delivery_grid.py2
-rw-r--r--addons/http_routing/models/ir_http.py5
-rw-r--r--addons/mail/models/mail_mail.py4
-rw-r--r--addons/mail/wizard/mail_template_preview.py2
-rw-r--r--addons/mrp/tests/test_stock.py4
-rw-r--r--addons/payment_authorize/controllers/main.py2
-rw-r--r--addons/point_of_sale/static/src/js/models.js12
-rw-r--r--addons/test_mail/tests/test_mail_channel.py10
-rw-r--r--addons/test_mail/tests/test_mail_message.py18
-rw-r--r--addons/web/controllers/main.py4
-rw-r--r--addons/web/static/src/js/services/crash_manager.js78
-rw-r--r--addons/web/static/tests/chrome/action_manager_tests.js1
-rw-r--r--addons/web_editor/static/src/js/editor/rte.js2
-rw-r--r--addons/website/models/ir_http.py2
-rw-r--r--addons/website_slides/controllers/main.py12
17 files changed, 57 insertions, 109 deletions
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='<p>This is First Message</p>', 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 = $('<div/>', {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}