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