[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
This commit is contained in:
@@ -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):
|
||||
|
||||
Reference in New Issue
Block a user