From f70a939dd5663f63d8974f3e3913836f348cc8b0 Mon Sep 17 00:00:00 2001 From: Mourad El Hadj Mimoune Date: Wed, 16 Mar 2016 14:49:24 +0100 Subject: [PATCH] [FIX] bug of file import related to api.multi --- attachment_metadata/models/attachment.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/attachment_metadata/models/attachment.py b/attachment_metadata/models/attachment.py index f2c0347f8..15e3e56a6 100644 --- a/attachment_metadata/models/attachment.py +++ b/attachment_metadata/models/attachment.py @@ -33,12 +33,15 @@ class IrAttachmentMetadata(models.Model): @api.depends('datas', 'external_hash') def _compute_hash(self): - if self.datas: - self.internal_hash = hashlib.md5(b64decode(self.datas)).hexdigest() - if self.external_hash and self.internal_hash != self.external_hash: - raise UserError( - _("File corrupted: Something was wrong with " - "the retrieved file, please relaunch the task.")) + for attachment in self: + if attachment.datas: + attachment.internal_hash = hashlib.md5( + b64decode(self.datas)).hexdigest() + if attachment.external_hash and\ + attachment.internal_hash != attachment.external_hash: + raise UserError( + _("File corrupted: Something was wrong with " + "the retrieved file, please relaunch the task.")) def _get_file_type(self): """This is the method to be inherited for adding file types