Browse Source
Merge pull request #1789 from ForgeFlow/12.0-fix-database-cleanup
[12.0][FIX] database_cleanup: only uninstall installed modules (greenify repo)
12.0-mig-module_prototyper_last
Jordi Ballester Alomar
5 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with
14 additions and
6 deletions
-
database_cleanup/__manifest__.py
-
database_cleanup/models/purge_modules.py
-
database_cleanup/tests/test_database_cleanup.py
|
@ -48,10 +48,19 @@ class CleanupPurgeLineModule(models.TransientModel): |
|
|
return True |
|
|
return True |
|
|
self.logger.info('Purging modules %s', ', '.join(module_names)) |
|
|
self.logger.info('Purging modules %s', ', '.join(module_names)) |
|
|
modules.filtered( |
|
|
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() |
|
|
).button_immediate_uninstall() |
|
|
modules.refresh() |
|
|
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}) |
|
|
return self.write({'purged': True}) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -3,12 +3,11 @@ |
|
|
from psycopg2 import ProgrammingError |
|
|
from psycopg2 import ProgrammingError |
|
|
from odoo.modules.registry import Registry |
|
|
from odoo.modules.registry import Registry |
|
|
from odoo.tools import config, mute_logger |
|
|
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): |
|
|
class TestDatabaseCleanup(TransactionCase): |
|
|
def setUp(self): |
|
|
def setUp(self): |
|
|
super(TestDatabaseCleanup, self).setUp() |
|
|
super(TestDatabaseCleanup, self).setUp() |
|
|