From d1452524426d895104910b082620e5e2d7f55932 Mon Sep 17 00:00:00 2001 From: Simone Orsi Date: Thu, 26 Mar 2026 10:36:12 +0100 Subject: [PATCH 1/3] base_rest: turn off deprecation logging on demand Disable logging for deprecation. You might have big projects, with tons of services with no specific decorator, that are well tested and very stable and you don't want to touch them. Especially if you plan already to move to v16. Since this logging can bloat your CI and your log collecting tools, here is a way to prevent that and get only a msg at boot. Once enabled, you'll see this msg in the logs only at start up: 'odoo.addons.base_rest.components.service: REST_API_METHOD_FIX_DECORATOR_DEPRECATE_LOG_DISABLE enabled: implicit service methods are deprecated. Disable this env key and enable debug level to have more details.' --- base_rest/components/service.py | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/base_rest/components/service.py b/base_rest/components/service.py index b8611bcf2..af14b6d3a 100644 --- a/base_rest/components/service.py +++ b/base_rest/components/service.py @@ -3,6 +3,7 @@ import logging +import os from werkzeug.exceptions import NotFound @@ -17,6 +18,23 @@ _logger = logging.getLogger(__name__) +# Disable logging for deprecation. +# You might have big projects, with tons of services with no specific decorator, +# that are well tested and very stable and you don't want to touch them. +# Especially if you plan already to move to v16. +# Since this logging can bloat your CI and your log collecting tools, +# here is a way to prevent that and get only a msg at boot. +DISABLE_DEPRECATE_LOG_KEY = "REST_API_METHOD_FIX_DECORATOR_DEPRECATE_LOG_DISABLE" +DISABLE_DEPRECATE_LOG = os.getenv(DISABLE_DEPRECATE_LOG_KEY) +if DISABLE_DEPRECATE_LOG: + msg = ( + "%s enabled: " + "implicit service methods are deprecated. " + "Disable this env key and enable debug level to have more details." + ) + _logger.warning(msg, DISABLE_DEPRECATE_LOG_KEY) + + def to_int(val): # The javascript VM ducktape only use float and so pass float # to the api, the werkzeug request interpret params as unicode @@ -127,7 +145,7 @@ def _prepare_response(self, method, result): return result routing = getattr(method, ROUTING_DECORATOR_ATTR, None) output_param = routing["output_param"] - if not output_param: + if not output_param and not DISABLE_DEPRECATE_LOG: _logger.warning( "DEPRECATED: You must define an output schema for method %s " "in service %s", From d689ffd4ea3cd9918bfd19d01a0907977b66abed Mon Sep 17 00:00:00 2001 From: Simone Orsi Date: Thu, 26 Mar 2026 10:38:42 +0100 Subject: [PATCH 2/3] oca-port: blacklist PR(s) https://github.com/OCA/rest-framework/pull/336 for base_rest --- .oca/oca-port/blacklist/base_rest.json | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .oca/oca-port/blacklist/base_rest.json diff --git a/.oca/oca-port/blacklist/base_rest.json b/.oca/oca-port/blacklist/base_rest.json new file mode 100644 index 000000000..89f030759 --- /dev/null +++ b/.oca/oca-port/blacklist/base_rest.json @@ -0,0 +1,5 @@ +{ + "pull_requests": { + "https://github.com/OCA/rest-framework/pull/336": "Nothing to port from PR #https://github.com/OCA/rest-framework/pull/336" + } +} From 343a277fd33bce626638fa14126452f55469876e Mon Sep 17 00:00:00 2001 From: Simone Orsi Date: Thu, 26 Mar 2026 11:12:30 +0100 Subject: [PATCH 3/3] fixup! base_rest: turn off deprecation logging on demand --- base_rest/components/service.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/base_rest/components/service.py b/base_rest/components/service.py index af14b6d3a..57a78aea7 100644 --- a/base_rest/components/service.py +++ b/base_rest/components/service.py @@ -145,15 +145,16 @@ def _prepare_response(self, method, result): return result routing = getattr(method, ROUTING_DECORATOR_ATTR, None) output_param = routing["output_param"] - if not output_param and not DISABLE_DEPRECATE_LOG: + if output_param: + return output_param.to_response(self, result) + elif not output_param and not DISABLE_DEPRECATE_LOG: _logger.warning( "DEPRECATED: You must define an output schema for method %s " "in service %s", method_name, self._name, ) - return result - return output_param.to_response(self, result) + return result def dispatch(self, method_name, *args, params=None): """