From 5fd3555e5de3e22d411df92328cd595b7ae28e5e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Bidoul?= Date: Wed, 25 Sep 2024 20:51:41 +0200 Subject: [PATCH] Adapt to Odoo 18 logging config changes --- click_odoo/env_options.py | 5 ++++- tests/test_click_odoo.py | 9 +++++---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/click_odoo/env_options.py b/click_odoo/env_options.py index 6b60d56..665f5b1 100644 --- a/click_odoo/env_options.py +++ b/click_odoo/env_options.py @@ -142,7 +142,10 @@ def _configure_odoo(self, ctx): odoo.tools.config["db_name"] = None # see https://github.com/odoo/odoo/commit/b122217f74 odoo.tools.config["load_language"] = None - odoo.tools.config.parse_config(odoo_args) + if odoo.release.version_info >= (18, 0): + odoo.tools.config.parse_config(odoo_args, setup_logging=True) + else: + odoo.tools.config.parse_config(odoo_args) odoo.cli.server.report_configuration() def _db_exists(self, dbname): diff --git a/tests/test_click_odoo.py b/tests/test_click_odoo.py index bd8d973..f494f52 100644 --- a/tests/test_click_odoo.py +++ b/tests/test_click_odoo.py @@ -18,10 +18,11 @@ here = os.path.abspath(os.path.dirname(__file__)) -# This hack is necessary because the way CliRunner patches -# stdout is not compatible with the Odoo logging initialization -# mechanism. Logging is therefore tested with subprocesses. -odoo.netsvc._logger_init = True +if odoo.release.version_info < (18, 0): + # This hack is necessary because the way CliRunner patches + # stdout is not compatible with the Odoo logging initialization + # mechanism. Logging is therefore tested with subprocesses. + odoo.netsvc._logger_init = True def _init_odoo_db(dbname):