From 786598da021f8bf7c593e30b54288bfccb1d89ca Mon Sep 17 00:00:00 2001 From: Adrian Torres Date: Tue, 18 Aug 2020 08:06:10 +0000 Subject: [PATCH] [IMP] *: avoid overrides of res.config.settings.execute Execute shouldn't really be overriden because it handles a very touchy case: module (un)installs, if it is poorly overriden it can create registry inconsistencies and can make databases crash in really dumb ways, since the module operations *need* to be performed at the end of the transaction (last). Most of the time, an override of set_values() does the same job and is much safer. This commit updates the `res.config.settings.execute()` documentation to reflect this. closes odoo/odoo#56032 Signed-off-by: Raphael Collet (rco) --- odoo/addons/base/models/res_config.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/odoo/addons/base/models/res_config.py b/odoo/addons/base/models/res_config.py index f2bbf89b009..fd9ddec2693 100644 --- a/odoo/addons/base/models/res_config.py +++ b/odoo/addons/base/models/res_config.py @@ -599,6 +599,20 @@ class ResConfigSettings(models.TransientModel, ResConfigModuleInstallationMixin) IrConfigParameter.set_param(icp, value) def execute(self): + """ + Called when settings are saved. + + This method will call `set_values` and will install/uninstall any modules defined by + `module_` Boolean fields and then trigger a web client reload. + + .. warning:: + + This method **SHOULD NOT** be overridden, in most cases what you want to override is + `~set_values()` since `~execute()` does little more than simply call `~set_values()`. + + The part that installs/uninstalls modules **MUST ALWAYS** be at the end of the + transaction, otherwise there's a big risk of registry <-> database desynchronisation. + """ self.ensure_one() if not self.env.is_admin(): raise AccessError(_("Only administrators can change the settings"))