diff --git a/database_cleanup/__openerp__.py b/database_cleanup/__manifest__.py similarity index 100% rename from database_cleanup/__openerp__.py rename to database_cleanup/__manifest__.py diff --git a/database_cleanup/models/purge_modules.py b/database_cleanup/models/purge_modules.py index 0cb799d22..c099e390d 100644 --- a/database_cleanup/models/purge_modules.py +++ b/database_cleanup/models/purge_modules.py @@ -48,10 +48,19 @@ class CleanupPurgeLineModule(models.TransientModel): return True self.logger.info('Purging modules %s', ', '.join(module_names)) modules.filtered( - lambda x: x.state not in ('uninstallable', 'uninstalled') + lambda x: x.state == 'to install' + ).write({'state': 'uninstalled'}) + modules.filtered( + lambda x: x.state in ('to upgrade', 'to remove') + ).write({'state': 'installed'}) + modules.filtered( + lambda x: x.state == 'installed' and x.name != 'base' ).button_immediate_uninstall() modules.refresh() - modules.unlink() + modules.filtered( + lambda x: x.state not in ( + 'installed', 'to upgrade', 'to remove', 'to install') + ).unlink() return self.write({'purged': True}) diff --git a/database_cleanup/tests/test_database_cleanup.py b/database_cleanup/tests/test_database_cleanup.py index 705b844f0..b05c804ea 100644 --- a/database_cleanup/tests/test_database_cleanup.py +++ b/database_cleanup/tests/test_database_cleanup.py @@ -3,12 +3,11 @@ from psycopg2 import ProgrammingError from odoo.modules.registry import Registry from odoo.tools import config, mute_logger -from odoo.tests.common import TransactionCase, at_install, post_install +from odoo.tests.common import TransactionCase, tagged -# Use post_install to get all models loaded more info: odoo/odoo#13458 -@at_install(False) -@post_install(True) +# Use post_install to get all models loaded, more info: odoo/odoo#13458 +@tagged('post_install', '-at_install') class TestDatabaseCleanup(TransactionCase): def setUp(self): super(TestDatabaseCleanup, self).setUp()