details:   https://code.tryton.org/tryton/commit/a7bc04a0430d
branch:    default
user:      Cédric Krier <[email protected]>
date:      Sat Aug 01 10:49:03 2026 +0200
description:
        Do not set twice the extension in the attachment name for the UBL 
documents

        Closes #14982
diffstat:

 modules/edocument_ubl/edocument.py |  7 +++++--
 1 files changed, 5 insertions(+), 2 deletions(-)

diffs (22 lines):

diff -r e1801f15caaa -r a7bc04a0430d modules/edocument_ubl/edocument.py
--- a/modules/edocument_ubl/edocument.py        Sat Aug 01 00:57:28 2026 +0200
+++ b/modules/edocument_ubl/edocument.py        Sat Aug 01 10:49:03 2026 +0200
@@ -1323,13 +1323,16 @@
                         ) is not None:
                     mime_code = (
                         data.get('mimeCode') or 'application/octet-stream')
-                    name += mimetypes.guess_extension(mime_code) or ''
+                    if extension := mimetypes.guess_extension(mime_code):
+                        if not name.lower().endswith(extension):
+                            name += extension
                     attachment.type = 'data'
                     data = b64decode(data.text)
                     attachment.data = data
                 elif data := document.findtext(
                         './{*}Attachment/{*}EmbeddedDocument'):
-                    name += '.txt'
+                    if not name.lower().endswith('.txt'):
+                        name += '.txt'
                     attachment.type = 'data'
                     attachment.data = data
                 elif url := document.findtext(

Reply via email to