Skip to content
Snippets Groups Projects
Commit cd4b50de authored by Adrian Torres's avatar Adrian Torres
Browse files

[FIX] base: don't uninstall already uninstalled modules


Before this commit:
    - Install some random module that can be uninstalled (so not base)
    - Open the uninstall wizard for said module in two different tabs /
        windows / whatever
    - In one tab, confirm the module uninstall and wait for it to be
        done
    - As soon as the other tab is done with the uninstall, go to the
        second one with the uninstall wizard still open, and proceed
        with the second uninstall
    - Boom, the registry crashes and completely fucks up the DB because
        there's no check at all that prevents the uninstall of already
        uninstalled modules.

After this commit:
    - `ir.module.module.button_uninstall` will check if all the
        modules being uninstalled are in the installed state
        and if not a UserError will be raised, preventing a second
        uninstall of the module which could potentially break the DB

Do note that this fix is LOCAL, the problem is however more or less
global, wherever there's user-actionable buttons that should only be
pressed once there's a potential for bugs / breakage if a similar fix is
not implemented locally. Perhaps a more global fix should be implemented
eventually, but it's generally less annoying for business cases since
those probably won't break the registry, see task 1859014.

opw-2213679
opw-2212594
opw-2206446

closes odoo/odoo#47450

X-original-commit: 8c1bb22e
Signed-off-by: default avatarAdrian Torres (adt) <adt@odoo.com>
parent 29e02270
No related branches found
No related tags found
No related merge requests found
......@@ -605,6 +605,11 @@ class Module(models.Model):
def button_uninstall(self):
if 'base' in self.mapped('name'):
raise UserError(_("The `base` module cannot be uninstalled"))
if not all(state == 'installed' for state in self.mapped('state')):
raise UserError(_(
"One or more of the selected modules have already been uninstalled, if you "
"believe this to be an error, you may try again later or contact support."
))
deps = self.downstream_dependencies()
(self + deps).write({'state': 'to remove'})
return dict(ACTION_DICT, name=_('Uninstall'))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment