From d0eafda3588a10dec3eb93f7bdb04ffd8529d535 Mon Sep 17 00:00:00 2001 From: Guewen Baconnier Date: Mon, 3 Feb 2014 11:32:54 +0100 Subject: [PATCH] avoid ''NoneType' object has no attribute 'exists'' error when purging models --- database_cleanup/model/purge_models.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/database_cleanup/model/purge_models.py b/database_cleanup/model/purge_models.py index 8355b4921..622df2955 100644 --- a/database_cleanup/model/purge_models.py +++ b/database_cleanup/model/purge_models.py @@ -65,8 +65,10 @@ class CleanupPurgeLineModel(orm.TransientModel): row = cr.fetchone() if row: self.logger.info('Purging model %s', row[1]) - attachment_ids = attachment_pool.search( - cr, uid, [('res_model', '=', line.name)], context=context) + cr.execute( + "UPDATE ir_attachment SET res_model = FALSE " + "WHERE id in %s", + (tuple(attachment_ids), )) if attachment_ids: attachment_pool.write( cr, uid, attachment_ids, {'res_model': False},