From b6537c4335356ed660d2acbd914783d4ceea2521 Mon Sep 17 00:00:00 2001 From: Julien Castiaux Date: Wed, 15 Apr 2020 14:52:08 +0000 Subject: [PATCH] [REV] base: restore removed deprecated osv and exceptions To ensure backward compatibility, stuff removed by ab4000fb3 have been restored. closes odoo/odoo#49603 Task: 2234749 Signed-off-by: Raphael Collet (rco) --- odoo/exceptions.py | 30 ++++++++++++++++++++---------- odoo/osv/__init__.py | 1 + odoo/osv/osv.py | 13 +++++++++++++ 3 files changed, 34 insertions(+), 10 deletions(-) create mode 100644 odoo/osv/osv.py diff --git a/odoo/exceptions.py b/odoo/exceptions.py index 8400194e75a..43281b8bca9 100644 --- a/odoo/exceptions.py +++ b/odoo/exceptions.py @@ -39,16 +39,6 @@ class UserError(Exception): return self.args[0] -# deprecated due to collision with builtins, kept for compatibility -class Warning(UserError): - def __init__(self, *args, **kwargs): - warnings.warn( - "Warning is a deprecated alias to UserError and is going to be " - "removed in a future version.", - DeprecationWarning) - super().__init__(*args, **kwargs) - - class RedirectWarning(Exception): """ Warning with a possibility to redirect the user instead of simply displaying the warning message. @@ -126,3 +116,23 @@ class ValidationError(UserError): When you try to create a new user with a login which already exist in the db. """ + + +# Deprecated exceptions, only kept for backward compatibility, may be +# removed in the future *without* any futher notice than the Deprecation +# Warning. + +class except_orm(UserError): + def __init__(self, *args, **kwargs): + warnings.warn("except_orm is a deprecated alias to UserError.", DeprecationWarning) + super().__init__(*args, **kwargs) + +class Warning(UserError): + def __init__(self, *args, **kwargs): + warnings.warn("Warning is a deprecated alias to UserError.", DeprecationWarning) + super().__init__(*args, **kwargs) + +class QWebException(Exception): + def __init__(self, *args, **kwargs): + warnings.warn("qweb.QWebException is the exception you are looking for.", DeprecationWarning) + super().__init__(*args, **kwargs) diff --git a/odoo/osv/__init__.py b/odoo/osv/__init__.py index 2903e8d9121..9399e4410fb 100644 --- a/odoo/osv/__init__.py +++ b/odoo/osv/__init__.py @@ -1,3 +1,4 @@ # -*- coding: utf-8 -*- # Part of Odoo. See LICENSE file for full copyright and licensing details. +from . import osv diff --git a/odoo/osv/osv.py b/odoo/osv/osv.py new file mode 100644 index 00000000000..c0de9c0973e --- /dev/null +++ b/odoo/osv/osv.py @@ -0,0 +1,13 @@ +# -*- coding: utf-8 -*- +# Part of Odoo. See LICENSE file for full copyright and licensing details. + +from ..exceptions import UserError +from ..models import Model, TransientModel, AbstractModel + +# Deprecated, kept for backward compatibility. +except_osv = UserError + +# Deprecated, kept for backward compatibility. +osv = Model +osv_memory = TransientModel +osv_abstract = AbstractModel # ;-)