summaryrefslogtreecommitdiff
path: root/odoo/service
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 /odoo/service
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 'odoo/service')
-rw-r--r--odoo/service/model.py10
-rw-r--r--odoo/service/wsgi_server.py26
2 files changed, 9 insertions, 27 deletions
diff --git a/odoo/service/model.py b/odoo/service/model.py
index 82a32c2cfc1..731007abd23 100644
--- a/odoo/service/model.py
+++ b/odoo/service/model.py
@@ -9,7 +9,7 @@ import threading
import time
import odoo
-from odoo.exceptions import UserError, ValidationError, QWebException
+from odoo.exceptions import UserError, ValidationError
from odoo.models import check_method_name
from odoo.tools.translate import translate, translate_sql_constraint
from odoo.tools.translate import _
@@ -91,13 +91,7 @@ def check(f):
if odoo.registry(dbname)._init and not odoo.tools.config['test_enable']:
raise odoo.exceptions.Warning('Currently, this database is not fully loaded and can not be used.')
return f(dbname, *args, **kwargs)
- except (OperationalError, QWebException) as e:
- if isinstance(e, QWebException):
- cause = e.qweb.get('cause')
- if isinstance(cause, OperationalError):
- e = cause
- else:
- raise
+ except OperationalError as e:
# Automatically retry the typical transaction serialization errors
if e.pgcode not in PG_CONCURRENCY_ERRORS_TO_RETRY:
raise
diff --git a/odoo/service/wsgi_server.py b/odoo/service/wsgi_server.py
index 65ca8806df9..c2712203804 100644
--- a/odoo/service/wsgi_server.py
+++ b/odoo/service/wsgi_server.py
@@ -35,22 +35,14 @@ RPC_FAULT_CODE_ACCESS_DENIED = 3
RPC_FAULT_CODE_ACCESS_ERROR = 4
def xmlrpc_handle_exception_int(e):
- if isinstance(e, odoo.exceptions.UserError):
- fault = xmlrpclib.Fault(RPC_FAULT_CODE_WARNING, odoo.tools.ustr(e.name))
- elif isinstance(e, odoo.exceptions.RedirectWarning):
+ if isinstance(e, odoo.exceptions.RedirectWarning):
fault = xmlrpclib.Fault(RPC_FAULT_CODE_WARNING, str(e))
- elif isinstance(e, odoo.exceptions.MissingError):
- fault = xmlrpclib.Fault(RPC_FAULT_CODE_WARNING, str(e))
- elif isinstance (e, odoo.exceptions.AccessError):
+ elif isinstance(e, odoo.exceptions.AccessError):
fault = xmlrpclib.Fault(RPC_FAULT_CODE_ACCESS_ERROR, str(e))
elif isinstance(e, odoo.exceptions.AccessDenied):
fault = xmlrpclib.Fault(RPC_FAULT_CODE_ACCESS_DENIED, str(e))
- elif isinstance(e, odoo.exceptions.DeferredException):
- info = e.traceback
- # Which one is the best ?
- formatted_info = "".join(traceback.format_exception(*info))
- #formatted_info = odoo.tools.exception_to_unicode(e) + '\n' + info
- fault = xmlrpclib.Fault(RPC_FAULT_CODE_APPLICATION_ERROR, formatted_info)
+ elif isinstance(e, odoo.exceptions.UserError):
+ fault = xmlrpclib.Fault(RPC_FAULT_CODE_WARNING, str(e))
else:
info = sys.exc_info()
# Which one is the best ?
@@ -61,9 +53,7 @@ def xmlrpc_handle_exception_int(e):
return xmlrpclib.dumps(fault, allow_none=None)
def xmlrpc_handle_exception_string(e):
- if isinstance(e, odoo.exceptions.UserError):
- fault = xmlrpclib.Fault('warning -- %s\n\n%s' % (e.name, e.value), '')
- elif isinstance(e, odoo.exceptions.RedirectWarning):
+ if isinstance(e, odoo.exceptions.RedirectWarning):
fault = xmlrpclib.Fault('warning -- Warning\n\n' + str(e), '')
elif isinstance(e, odoo.exceptions.MissingError):
fault = xmlrpclib.Fault('warning -- MissingError\n\n' + str(e), '')
@@ -71,10 +61,8 @@ def xmlrpc_handle_exception_string(e):
fault = xmlrpclib.Fault('warning -- AccessError\n\n' + str(e), '')
elif isinstance(e, odoo.exceptions.AccessDenied):
fault = xmlrpclib.Fault('AccessDenied', str(e))
- elif isinstance(e, odoo.exceptions.DeferredException):
- info = e.traceback
- formatted_info = "".join(traceback.format_exception(*info))
- fault = xmlrpclib.Fault(odoo.tools.ustr(e), formatted_info)
+ elif isinstance(e, odoo.exceptions.UserError):
+ fault = xmlrpclib.Fault('warning -- UserError\n\n' + str(e), '')
#InternalError
else:
info = sys.exc_info()