From 95e0b9c96f62cb9e85fc6e2304a5af0145a048e8 Mon Sep 17 00:00:00 2001 From: Holger Brunn Date: Tue, 5 Sep 2017 19:55:45 +0200 Subject: [PATCH] [FIX] don't try to uninstall uninstalled modules --- database_cleanup/models/purge_modules.py | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/database_cleanup/models/purge_modules.py b/database_cleanup/models/purge_modules.py index ac9276e2c..fb8e0ad77 100644 --- a/database_cleanup/models/purge_modules.py +++ b/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})