From 6b74ea45e1961bd879f7b6c691766a6cb9c4ecb7 Mon Sep 17 00:00:00 2001 From: Thomas Rehn Date: Mon, 29 Aug 2016 17:33:44 +0200 Subject: [PATCH] [IMP] apply file directly to local file if storage is 'file' --- attachment_preview/model/ir_attachment.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/attachment_preview/model/ir_attachment.py b/attachment_preview/model/ir_attachment.py index da8c86d7..4c934c46 100644 --- a/attachment_preview/model/ir_attachment.py +++ b/attachment_preview/model/ir_attachment.py @@ -61,8 +61,13 @@ class IrAttachment(Model): hasattr(magic, 'MAGIC_MIME_TYPE') and magic.MAGIC_MIME_TYPE or magic.MAGIC_MIME) ms.load() - mimetype = ms.buffer( - base64.b64decode(this[binary_field])) + if model == self._name and binary_field == 'datas'\ + and this.store_fname: + mimetype = ms.file( + this._full_path(cr, uid, this.store_fname)) + else: + mimetype = ms.buffer( + base64.b64decode(this[binary_field])) except ImportError: (mimetype, encoding) = mimetypes.guess_type( 'data:;base64,' + this[binary_field], strict=False)