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
parent
commit
50f3dfcc7a
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 0
      database_cleanup/__manifest__.py
  2. 13
      database_cleanup/models/purge_modules.py
  3. 7
      database_cleanup/tests/test_database_cleanup.py

0
database_cleanup/__openerp__.py → database_cleanup/__manifest__.py

13
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})

7
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()

Loading…
Cancel
Save