Browse Source

[FIX] bug of file import related to api.multi

pull/515/head
Mourad El Hadj Mimoune 9 years ago
committed by Florian da Costa
parent
commit
785691d6ca
  1. 15
      attachment_metadata/models/attachment.py

15
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

Loading…
Cancel
Save