From 807af7f34e65a6f356bc84d5d5157ae23011a635 Mon Sep 17 00:00:00 2001 From: MuK IT GmbH Date: Sun, 18 Nov 2018 17:29:36 +0000 Subject: [PATCH] publish muk_utils - 12.0 --- muk_utils/__manifest__.py | 2 +- muk_utils/models/ir_attachment.py | 14 +++++++++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/muk_utils/__manifest__.py b/muk_utils/__manifest__.py index 6a7ce26..8031286 100644 --- a/muk_utils/__manifest__.py +++ b/muk_utils/__manifest__.py @@ -20,7 +20,7 @@ { "name": "MuK Utils", "summary": """Utility Features""", - "version": '12.0.1.1.4', + "version": '12.0.1.1.5', "category": 'Extra Tools', "license": "AGPL-3", "author": "MuK IT", diff --git a/muk_utils/models/ir_attachment.py b/muk_utils/models/ir_attachment.py index bd7e2c9..0a054a8 100644 --- a/muk_utils/models/ir_attachment.py +++ b/muk_utils/models/ir_attachment.py @@ -23,6 +23,7 @@ import mimetypes from odoo import api, models, _ from odoo.exceptions import AccessError +from odoo.tools.mimetypes import guess_mimetype _logger = logging.getLogger(__name__) @@ -59,4 +60,15 @@ class Attachment(models.Model): storage = self._storage().upper() for index, attach in enumerate(self): _logger.info(_("Migrate Attachment %s of %s to %s") % (index + 1, record_count, storage)) - attach.write({'datas': attach.datas}) + attach.with_context(migration=True).write({'datas': attach.datas}) + + #---------------------------------------------------------- + # Read + #---------------------------------------------------------- + + def _compute_mimetype(self, values): + if self.env.context.get('migration') and len(self) == 1: + return self.mimetype or 'application/octet-stream' + else: + return super(Attachment, self)._compute_mimetype(values) + \ No newline at end of file