[FIX] base: set_value

By default, the `set_value` method doesn't do anything, and is expected
to be overridden. However, `ir.default`, groups and
`ir.config_parameter` are set BEFORE `set_value` is actually called.

This is an issue when it is necessary to retrieve one of these values
before the save, for example in order to compare the value before and
after.

We move the setting of the various values directly in the `set_value`.
This way, it becomes possible to interact with the values before any
modification is performed. On the other hand, the existing logic remains
unchanged.

opw-1882068
This commit is contained in:
Nicolas Martinelli
2018-09-17 08:28:38 +02:00
committed by Nicolas Martinelli
parent ea0b3d600d
commit de1b97f493
+10 -8
View File
@@ -551,14 +551,6 @@ class ResConfigSettings(models.TransientModel, ResConfigModuleInstallationMixin)
"""
Set values for the fields other that `default`, `group` and `module`
"""
pass
@api.multi
def execute(self):
self.ensure_one()
if not self.env.user._is_superuser() and not self.env.user.has_group('base.group_system'):
raise AccessError(_("Only administrators can change the settings"))
self = self.with_context(active_test=False)
classified = self._get_classified_fields()
@@ -608,6 +600,16 @@ class ResConfigSettings(models.TransientModel, ResConfigModuleInstallationMixin)
for method in dir(self):
if method.startswith('set_') and method is not 'set_values':
_logger.warning(_('Methods that start with `set_` are deprecated. Override `set_values` instead (Method %s)') % method)
@api.multi
def execute(self):
self.ensure_one()
if not self.env.user._is_superuser() and not self.env.user.has_group('base.group_system'):
raise AccessError(_("Only administrators can change the settings"))
self = self.with_context(active_test=False)
classified = self._get_classified_fields()
self.set_values()
# module fields: install/uninstall the selected modules