From 2fc6e94d8ae96f1570da63e8883e81044b8dc4dc Mon Sep 17 00:00:00 2001 From: Denis Ledoux Date: Wed, 18 Nov 2015 14:23:10 +0100 Subject: [PATCH] [FIX] ir.config.parameter: set_param with None/False as value Use `ir.config.parameter`.`set_param` with `None` or `False` was not allowed as `value` of a `ir.config.parameter` is required. An attempt to set a system parameter to `None` or `False` means, most of the time, that the system parameter should be dropped. For instance, in configuration wizards (`res.config`), `set_param` is used when boxes are checked, or fields are filled, to create/update system parameters with the value given in the configuration wizards. When unchecking these boxes, the configurations wizards tried to set `None` in the system parameters, leading to a warning saying the value is mandatory. The behavior expected when unchecking these boxes was to remove the system parameters, not to leave them empty. Besides, there is not methods available in `ir.config.parameter` to quickly remove a system parameter, like there is one to set a parameter. opw-653547 --- openerp/addons/base/ir/ir_config_parameter.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/openerp/addons/base/ir/ir_config_parameter.py b/openerp/addons/base/ir/ir_config_parameter.py index c6b02ae7cda..da34d8964c5 100644 --- a/openerp/addons/base/ir/ir_config_parameter.py +++ b/openerp/addons/base/ir/ir_config_parameter.py @@ -96,11 +96,15 @@ class ir_config_parameter(osv.osv): if ids: param = self.browse(cr, uid, ids[0], context=context) old = param.value - self.write(cr, uid, ids, vals, context=context) + if value is not False and value is not None: + self.write(cr, uid, ids, vals, context=context) + else: + self.unlink(cr, uid, ids, context=context) return old else: vals.update(key=key) - self.create(cr, uid, vals, context=context) + if value is not False and value is not None: + self.create(cr, uid, vals, context=context) return False def write(self, cr, uid, ids, vals, context=None):