diff --git a/fs_attachment/models/ir_binary.py b/fs_attachment/models/ir_binary.py index 57f6b2d5e4..d170572dc8 100644 --- a/fs_attachment/models/ir_binary.py +++ b/fs_attachment/models/ir_binary.py @@ -1,12 +1,14 @@ # Copyright 2023 ACSONE SA/NV # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). import logging +from mimetypes import guess_extension import werkzeug.http from odoo import models from odoo.http import request from odoo.tools.image import image_process +from odoo.tools.mimetypes import get_extension from ..fs_stream import FsStream @@ -74,6 +76,12 @@ def _get_stream_from( elif record and filename_field in record: stream.download_name = record[filename_field] or stream.download_name + if ( + not get_extension(stream.download_name) + and stream.mimetype != "application/octet-stream" + ): + stream.download_name += guess_extension(stream.mimetype) or "" + return stream def _get_image_stream_from(