From 4d9a0e47d82f43f97835ee80eacb329658ee92c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Sat, 1 Aug 2026 10:49:03 +0200 Subject: [PATCH] Do not set twice the extension in the attachment name for the UBL documents Closes #14982 --- modules/edocument_ubl/edocument.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/modules/edocument_ubl/edocument.py b/modules/edocument_ubl/edocument.py index 2c952f9826..51dfe67da6 100644 --- a/modules/edocument_ubl/edocument.py +++ b/modules/edocument_ubl/edocument.py @@ -1323,13 +1323,16 @@ class Invoice(Model): ) 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(