From 668742e89bc5aa3ec701b3c2c227a8103ddd3c34 Mon Sep 17 00:00:00 2001 From: Guewen Baconnier Date: Mon, 3 Feb 2014 11:30:25 +0100 Subject: [PATCH] remove relations when purging models --- database_cleanup/model/purge_models.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/database_cleanup/model/purge_models.py b/database_cleanup/model/purge_models.py index 8355b4921..f6e264984 100644 --- a/database_cleanup/model/purge_models.py +++ b/database_cleanup/model/purge_models.py @@ -51,6 +51,7 @@ class CleanupPurgeLineModel(orm.TransientModel): model_pool = self.pool['ir.model'] attachment_pool = self.pool['ir.attachment'] constraint_pool = self.pool['ir.model.constraint'] + fields_pool = self.pool['ir.model.fields'] local_context=(context or {}).copy() local_context.update({ @@ -76,6 +77,11 @@ class CleanupPurgeLineModel(orm.TransientModel): if constraint_ids: constraint_pool.unlink( cr, uid, constraint_ids, context=context) + relation_ids = fields_pool.search( + cr, uid, [('relation', '=', row[1])], context=context) + if relation_ids: + fields_pool.unlink(cr, uid, relation_ids, + context=local_context) model_pool.unlink(cr, uid, [row[0]], context=local_context) line.write({'purged': True}) cr.commit()