Browse Source

Merge PR #1822 into 12.0

Signed-off-by legalsylvain
12.0-mig-module_prototyper_last
OCA-git-bot 5 years ago
parent
commit
32a7cec4af
  1. 7
      database_cleanup/models/purge_models.py
  2. 6
      database_cleanup/tests/test_database_cleanup.py
  3. 3
      requirements.txt

7
database_cleanup/models/purge_models.py

@ -73,6 +73,13 @@ class CleanupPurgeLineModel(models.TransientModel):
self.env['ir.model.constraint'].search([
('model', '=', line.name),
]).unlink()
cronjobs = self.env['ir.cron'].with_context(
active_test=False
).search([
('model_id.model', '=', line.name),
])
if cronjobs:
cronjobs.unlink()
relations = self.env['ir.model.fields'].search([
('relation', '=', row[1]),
]).with_context(**context_flags)

6
database_cleanup/tests/test_database_cleanup.py

@ -73,6 +73,11 @@ class TestDatabaseCleanup(TransactionCase):
'name': 'Database cleanup test model',
'model': 'x_database.cleanup.test.model',
})
# and a cronjob for it
cronjob = self.env['ir.cron'].create({
'name': 'testcronjob',
'model_id': self.models.id,
})
self.env.cr.execute(
'insert into ir_attachment (name, res_model, res_id, type) values '
"('test attachment', 'database.cleanup.test.model', 42, 'binary')")
@ -83,6 +88,7 @@ class TestDatabaseCleanup(TransactionCase):
self.assertFalse(self.env['ir.model'].search([
('model', '=', 'x_database.cleanup.test.model'),
]))
self.assertFalse(cronjob.exists())
# create an orphaned table
self.env.cr.execute('create table database_cleanup_test (test int)')

3
requirements.txt

@ -3,4 +3,5 @@ openpyxl
xlrd
xlwt
pysftp
pygount
# version 1.2.0 deprecates the API module_analysis uses
pygount<1.2.0
Loading…
Cancel
Save