[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) <rco@openerp.com>
This commit is contained in:
committed by
Raphael Collet
parent
d04aeb6b37
commit
786598da02
@@ -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"))
|
||||
|
||||
Reference in New Issue
Block a user