summaryrefslogtreecommitdiff
path: root/odoo/tools/config.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 /odoo/tools/config.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 'odoo/tools/config.py')
-rw-r--r--odoo/tools/config.py27
1 files changed, 21 insertions, 6 deletions
diff --git a/odoo/tools/config.py b/odoo/tools/config.py
index c9f6e2556c3..a50e3a8460c 100644
--- a/odoo/tools/config.py
+++ b/odoo/tools/config.py
@@ -9,6 +9,7 @@ import glob
import os
import sys
import tempfile
+import warnings
import odoo
from os.path import expandvars, expanduser, abspath, realpath
from .. import release, conf, loglevels
@@ -280,10 +281,12 @@ class configmanager(object):
help="Force a limit on the maximum number of records kept in the virtual "
"osv_memory tables. The default is False, which means no count-based limit.",
type="int")
- group.add_option("--osv-memory-age-limit", dest="osv_memory_age_limit", my_default=1.0,
- help="Force a limit on the maximum age of records kept in the virtual "
- "osv_memory tables. This is a decimal value expressed in hours, "
- "and the default is 1 hour.",
+ group.add_option("--transient-age-limit", dest="transient_age_limit", my_default=1.0,
+ help="Time limit (decimal value in hours) records created with a "
+ "TransientModel (mosly wizard) are kept in the database. Default to 1 hour.",
+ type="float")
+ group.add_option("--osv-memory-age-limit", dest="osv_memory_age_limit", my_default=False,
+ help="Deprecated alias to the transient-age-limit option",
type="float")
group.add_option("--max-cron-threads", dest="max_cron_threads", my_default=2,
help="Maximum number of threads processing concurrently cron jobs (default 2).",
@@ -350,6 +353,7 @@ class configmanager(object):
"""
opt = self._parse_config(args)
odoo.netsvc.init_logger()
+ self._warn_deprecated_options()
odoo.modules.module.initialize_sys_path()
return opt
@@ -382,6 +386,10 @@ class configmanager(object):
"The config file '%s' selected with -c/--config doesn't exist or is not readable, "\
"use -s/--save if you want to generate it"% opt.config)
+ die(bool(opt.osv_memory_age_limit) and bool(opt.transient_memory_age_limit),
+ "the osv-memory-count-limit option cannot be used with the "
+ "transient-age-limit option, please only use the latter.")
+
# place/search the config file on Win32 near the server installation
# (../etc from the server)
# if the server is run by an unprivileged user, he has to specify location of a config file where he has the rights to write,
@@ -448,7 +456,7 @@ class configmanager(object):
'stop_after_init', 'without_demo', 'http_enable', 'syslog',
'list_db', 'proxy_mode',
'test_file', 'test_tags',
- 'osv_memory_count_limit', 'osv_memory_age_limit', 'max_cron_threads', 'unaccent',
+ 'osv_memory_count_limit', 'osv_memory_age_limit', 'transient_age_limit', 'max_cron_threads', 'unaccent',
'data_dir',
'server_wide_modules',
]
@@ -525,9 +533,16 @@ class configmanager(object):
conf.server_wide_modules = [
m.strip() for m in self.options['server_wide_modules'].split(',') if m.strip()
]
-
return opt
+ def _warn_deprecated_options(self):
+ if self.options['osv_memory_age_limit']:
+ warnings.warn(
+ "The osv-memory-age-limit is a deprecated alias to "
+ "the transient-age-limit option, please use the latter.",
+ DeprecationWarning)
+ self.options['transient_age_limit'] = self.options.pop('osv_memory_age_limit')
+
def _is_addons_path(self, path):
from odoo.modules.module import MANIFEST_NAMES
for f in os.listdir(path):