From de1b97f493ade153b2faea16efc5b3d2afd09661 Mon Sep 17 00:00:00 2001 From: Nicolas Martinelli Date: Thu, 13 Sep 2018 15:44:27 +0200 Subject: [PATCH] [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 --- odoo/addons/base/models/res_config.py | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/odoo/addons/base/models/res_config.py b/odoo/addons/base/models/res_config.py index ece9100e2e9..6b84f4f17ae 100644 --- a/odoo/addons/base/models/res_config.py +++ b/odoo/addons/base/models/res_config.py @@ -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