[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@39fb3be0ef 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) <mat@odoo.com>


Co-authored-by: Martin Trigaux <mat@odoo.com>
This commit is contained in:
Denis Roussel
2019-05-23 09:04:22 +00:00
committed by Martin Trigaux
co-authored by Martin Trigaux
parent 57bb236c24
commit c057708447
+1 -1
View File
@@ -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'