Browse Source

[FIX] don't try to uninstall uninstalled modules

pull/894/head^2
Holger Brunn 7 years ago
parent
commit
95e0b9c96f
No known key found for this signature in database GPG Key ID: 1C9760FECA3AE18
  1. 9
      database_cleanup/models/purge_modules.py

9
database_cleanup/models/purge_modules.py

@ -3,7 +3,6 @@
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from odoo import _, api, fields, models
from odoo.exceptions import UserError
from odoo.modules.registry import RegistryManager
from odoo.modules.module import get_module_path
from odoo.addons.base.ir.ir_model import MODULE_UNINSTALL_FLAG
@ -53,11 +52,9 @@ class CleanupPurgeLineModule(models.TransientModel):
if not modules:
return True
self.logger.info('Purging modules %s', ', '.join(module_names))
modules.button_immediate_uninstall()
# we need this commit because reloading the registry would roll back
# our changes
self.env.cr.commit() # pylint: disable=invalid-commit
RegistryManager.new(self.env.cr.dbname, update_module=True)
modules.filtered(
lambda x: x.state not in ('uninstallable', 'uninstalled')
).button_immediate_uninstall()
modules.refresh()
modules.unlink()
return objs.write({'purged': True})

Loading…
Cancel
Save