diff --git a/database_cleanup/models/purge_properties.py b/database_cleanup/models/purge_properties.py index 7adbf440b..3897862cc 100644 --- a/database_cleanup/models/purge_properties.py +++ b/database_cleanup/models/purge_properties.py @@ -4,6 +4,8 @@ from odoo import api, models, fields REASON_DUPLICATE = 1 REASON_DEFAULT = 2 +REASON_DEFAULT_FALSE = 3 +REASON_UNKNOWN_MODEL = 4 class CleanupPurgeLineProperty(models.TransientModel): @@ -17,6 +19,8 @@ class CleanupPurgeLineProperty(models.TransientModel): reason = fields.Selection([ (REASON_DUPLICATE, 'Duplicated property'), (REASON_DEFAULT, 'Same value as default'), + (REASON_DEFAULT_FALSE, 'Empty default property'), + (REASON_UNKNOWN_MODEL, 'Unknown model'), ]) @api.multi @@ -42,6 +46,27 @@ class CleanupPurgeWizardProperty(models.TransientModel): ]) handled_field_ids = [] for prop in default_properties: + value = None + try: + value = prop.get_by_record() + except KeyError: + result.append({ + 'name': '%s@%s: %s' % ( + prop.name, prop.res_id, value, + ), + 'property_id': prop.id, + 'reason': REASON_UNKNOWN_MODEL, + }) + continue + if not value: + result.append({ + 'name': '%s@%s: %s' % ( + prop.name, prop.res_id, value, + ), + 'property_id': prop.id, + 'reason': REASON_DEFAULT_FALSE, + }) + continue if prop.fields_id.id in handled_field_ids: continue domain = [ @@ -76,7 +101,8 @@ class CleanupPurgeWizardProperty(models.TransientModel): for redundant_property in self.env['ir.property'].search(domain): result.append({ 'name': '%s@%s: %s' % ( - prop.name, prop.res_id, prop.get_by_record() + prop.name, redundant_property.res_id, + prop.get_by_record() ), 'property_id': redundant_property.id, 'reason': REASON_DEFAULT, diff --git a/database_cleanup/views/create_indexes.xml b/database_cleanup/views/create_indexes.xml index 714db354a..36ef1f3c1 100644 --- a/database_cleanup/views/create_indexes.xml +++ b/database_cleanup/views/create_indexes.xml @@ -39,7 +39,7 @@ ir.actions.server code - env.get('cleanup.create_indexes.line').purge() + records.purge() diff --git a/database_cleanup/views/purge_columns.xml b/database_cleanup/views/purge_columns.xml index 23eefaaef..850e08166 100644 --- a/database_cleanup/views/purge_columns.xml +++ b/database_cleanup/views/purge_columns.xml @@ -37,9 +37,7 @@ ir.actions.server code - - env.get('cleanup.purge.line.column').purge() - + records.purge() diff --git a/database_cleanup/views/purge_data.xml b/database_cleanup/views/purge_data.xml index c6804a38a..99c192c1b 100644 --- a/database_cleanup/views/purge_data.xml +++ b/database_cleanup/views/purge_data.xml @@ -37,9 +37,7 @@ ir.actions.server code - - env.get('cleanup.purge.line.data').purge() - + records.purge() diff --git a/database_cleanup/views/purge_menus.xml b/database_cleanup/views/purge_menus.xml index 0757088d4..e12d811c2 100644 --- a/database_cleanup/views/purge_menus.xml +++ b/database_cleanup/views/purge_menus.xml @@ -33,9 +33,7 @@ ir.actions.server code - - env.get('cleanup.purge.line.menu').purge() - + records.purge() diff --git a/database_cleanup/views/purge_models.xml b/database_cleanup/views/purge_models.xml index b0dfa7e0d..9f3d4aade 100644 --- a/database_cleanup/views/purge_models.xml +++ b/database_cleanup/views/purge_models.xml @@ -33,9 +33,7 @@ ir.actions.server code - - env.get('cleanup.purge.line.model').purge() - + records.purge() diff --git a/database_cleanup/views/purge_modules.xml b/database_cleanup/views/purge_modules.xml index 549563a96..dc8ee7027 100644 --- a/database_cleanup/views/purge_modules.xml +++ b/database_cleanup/views/purge_modules.xml @@ -33,9 +33,7 @@ ir.actions.server code - - env.get('cleanup.purge.line.module').purge() - + records.purge() diff --git a/database_cleanup/views/purge_properties.xml b/database_cleanup/views/purge_properties.xml index f1a472293..16bb988fc 100644 --- a/database_cleanup/views/purge_properties.xml +++ b/database_cleanup/views/purge_properties.xml @@ -33,7 +33,7 @@ ir.actions.server code - env.get('cleanup.purge.line.property').purge() + records.purge() diff --git a/database_cleanup/views/purge_tables.xml b/database_cleanup/views/purge_tables.xml index d7d5a849f..80cff1fee 100644 --- a/database_cleanup/views/purge_tables.xml +++ b/database_cleanup/views/purge_tables.xml @@ -33,9 +33,7 @@ ir.actions.server code - - env.get('cleanup.purge.line.table').purge() - + records.purge()