From c0577084478afc255d6ab4f3c8d35cb124ead67c Mon Sep 17 00:00:00 2001 From: Denis Roussel Date: Tue, 21 May 2019 08:51:42 +0000 Subject: [PATCH] [FIX] base: support default boolean values in config_parameter Commit a0dd81b added 'magic' support for ir.config_parameter to res.config.settings fields. However for boolean fields, we have: IrConfigParameter.get_param(icp, field.default(self) if field.default else False) if value is False we do nothing. If icp is defined we get a str. Now if field.default(self) is truthy, it will be called with value.lower(). In particular if value is the boolean True, it will crash and thus settings are rendered inaccessible. Note that commit odoo/enterprise@39fb3be0ef0 gave a default '' value to a boolean field, sidestepping the issue. By convention, config_parameters encode booleans using bool(str), i.e. '' encodes False, while anything else encodes True. We follow this convention here; which means that "False" would be be interpreted as True (to Tarski's dismay). Note that passing a default True value would mean that the config_parameter would be False before the first settings save, which could be avoided by putting the value in the module data. opw-2000718 Closes odoo/odoo#33517 Signed-off-by: Martin Trigaux (mat) Co-authored-by: Martin Trigaux --- odoo/addons/base/models/res_config.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/odoo/addons/base/models/res_config.py b/odoo/addons/base/models/res_config.py index 32beb3b5742..da003cb73bd 100644 --- a/odoo/addons/base/models/res_config.py +++ b/odoo/addons/base/models/res_config.py @@ -543,7 +543,7 @@ class ResConfigSettings(models.TransientModel, ResConfigModuleInstallationMixin) _logger.warning(WARNING_MESSAGE, value, field, icp) value = 0.0 elif field.type == 'boolean': - value = value.lower() == 'true' + value = bool(value) res[name] = value # other fields: call the method 'get_values'