From 4ea883fe147f53a55f370c6c2d8dd5aac53dce5c Mon Sep 17 00:00:00 2001 From: Holger Brunn Date: Mon, 11 Feb 2019 13:39:00 +0100 Subject: [PATCH] [FIX] don't destroy values when there are empty default properties --- database_cleanup/models/purge_properties.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/database_cleanup/models/purge_properties.py b/database_cleanup/models/purge_properties.py index 9cd32d3f0..7a77c8943 100644 --- a/database_cleanup/models/purge_properties.py +++ b/database_cleanup/models/purge_properties.py @@ -4,6 +4,7 @@ from odoo import api, models, fields REASON_DUPLICATE = 1 REASON_DEFAULT = 2 +REASON_DEFAULT_FALSE = 3 class CleanupPurgeLineProperty(models.TransientModel): @@ -17,6 +18,7 @@ class CleanupPurgeLineProperty(models.TransientModel): reason = fields.Selection([ (REASON_DUPLICATE, 'Duplicated property'), (REASON_DEFAULT, 'Same value as default'), + (REASON_DEFAULT_FALSE, 'Empty default property'), ]) @api.multi @@ -42,6 +44,15 @@ class CleanupPurgeWizardProperty(models.TransientModel): ]) handled_field_ids = [] for prop in default_properties: + if not prop.get_by_record(): + result.append({ + 'name': '%s@%s: %s' % ( + prop.name, prop.res_id, prop.get_by_record() + ), + 'property_id': prop.id, + 'reason': REASON_DEFAULT_FALSE, + }) + continue if prop.fields_id.id in handled_field_ids: continue domain = [