Skip to content

Commit

Permalink
[FIX] don't try to uninstall uninstalled modules
Browse files Browse the repository at this point in the history
  • Loading branch information
hbrunn committed Sep 5, 2017
1 parent 55fd3d5 commit 95e0b9c
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions database_cleanup/models/purge_modules.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -53,11 +52,9 @@ def purge(self):
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})
Expand Down

0 comments on commit 95e0b9c

Please sign in to comment.