From 626c1579646c177a5dd7bd263f8cf56231a2e8f9 Mon Sep 17 00:00:00 2001 From: Akim Juillerat Date: Fri, 1 Mar 2019 18:56:54 +0100 Subject: [PATCH] [IMP]: Allow to use context Key as storage key --- base_attachment_object_storage/models/ir_attachment.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/base_attachment_object_storage/models/ir_attachment.py b/base_attachment_object_storage/models/ir_attachment.py index 51303bd..85296c8 100644 --- a/base_attachment_object_storage/models/ir_attachment.py +++ b/base_attachment_object_storage/models/ir_attachment.py @@ -156,7 +156,9 @@ class IrAttachment(models.Model): location = self.env.context.get('storage_location') or self._storage() if location in self._get_stores(): bin_data = base64.b64decode(value) - key = self._compute_checksum(bin_data) + key = self.env.context.get('force_storage_key') + if not key: + key = self._compute_checksum(bin_data) filename = self._store_file_write(key, bin_data) else: filename = super(IrAttachment, self)._file_write(value, checksum)