From eb46f3a2a710425ad0f6fe0a1a4c72d1c81a8bbe Mon Sep 17 00:00:00 2001 From: Stefan Rijnhart Date: Wed, 18 Feb 2015 19:15:14 +0100 Subject: [PATCH] [FIX] Avoid write trigger --- attachment_file_type/models/ir_attachment.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/attachment_file_type/models/ir_attachment.py b/attachment_file_type/models/ir_attachment.py index 76eb8011..289f0b60 100644 --- a/attachment_file_type/models/ir_attachment.py +++ b/attachment_file_type/models/ir_attachment.py @@ -63,7 +63,12 @@ class Attachment(orm.Model): logger.debug( 'Found file type %s for attachment with id %s', file_type, attachment.id) - attachment.write({'file_type': file_type}) + # Use SQL, not ORM, to prevent write triggers which are harmful + # in 6.1 on attachments of which the model or the record no longer + # exists + cr.execute( + "UPDATE ir_attachment SET file_type = %s WHERE id = %s", + (file_type, attachment_id)) return True def write(self, cr, uid, ids, vals, context=None):