summaryrefslogtreecommitdiff
path: root/addons/test_mail/tests/test_mail_channel.py
diff options
context:
space:
mode:
authorJulien Castiaux <juc@odoo.com>2020-02-19 13:34:27 +0000
committerRaphael Collet <rco@odoo.com>2020-04-08 08:41:17 +0000
commitab4000fb3cf8fa54ba714ceceec391b78d73755e (patch)
treeb28702ae04a1ce3628f9c6a3ffbd4a9c95324d4d /addons/test_mail/tests/test_mail_channel.py
parent640e63e371a511c0d6786154408c6f5704077947 (diff)
[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) <rco@openerp.com>
Diffstat (limited to 'addons/test_mail/tests/test_mail_channel.py')
-rw-r--r--addons/test_mail/tests/test_mail_channel.py10
1 files changed, 3 insertions, 7 deletions
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