Skip to content

Commit 68ded66

Browse files
committed
Merge PR #584 into 18.0
Signed-off-by lmignon
2 parents 3952ed1 + 21d669f commit 68ded66

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

fs_attachment/models/ir_binary.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
# Copyright 2023 ACSONE SA/NV
22
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
33
import logging
4+
from mimetypes import guess_extension
45

56
import werkzeug.http
67

78
from odoo import models
89
from odoo.http import request
910
from odoo.tools.image import image_process
11+
from odoo.tools.mimetypes import get_extension
1012

1113
from ..fs_stream import FsStream
1214

@@ -73,6 +75,12 @@ def _get_stream_from(
7375
elif record and filename_field in record:
7476
stream.download_name = record[filename_field] or stream.download_name
7577

78+
if (
79+
not get_extension(stream.download_name)
80+
and stream.mimetype != "application/octet-stream"
81+
):
82+
stream.download_name += guess_extension(stream.mimetype) or ""
83+
7684
return stream
7785

7886
def _get_image_stream_from(

0 commit comments

Comments
 (0)