details: https://code.tryton.org/tryton/commit/af3cd28a3347
branch: default
user: Cédric Krier <[email protected]>
date: Thu Mar 26 08:14:45 2026 +0100
description:
Filter the MIME type of the additional documents in UBL allowed by the
specification
Closes #14708
diffstat:
modules/edocument_ubl/CHANGELOG | 1 +
modules/edocument_ubl/edocument.py | 20 ++++++++++++++++++++
modules/edocument_ubl/template/2/CreditNote.xml | 2 +-
modules/edocument_ubl/template/2/Invoice.xml | 2 +-
4 files changed, 23 insertions(+), 2 deletions(-)
diffs (62 lines):
diff -r 1862b6634dc3 -r af3cd28a3347 modules/edocument_ubl/CHANGELOG
--- a/modules/edocument_ubl/CHANGELOG Mon Mar 23 16:08:13 2026 +0100
+++ b/modules/edocument_ubl/CHANGELOG Thu Mar 26 08:14:45 2026 +0100
@@ -1,3 +1,4 @@
+* Filter the MIME type of the additional documents allowed by the specification
* Use VATEX as tax exemption reason code
* Add support for Python 3.14
* Remove support for Python 3.9
diff -r 1862b6634dc3 -r af3cd28a3347 modules/edocument_ubl/edocument.py
--- a/modules/edocument_ubl/edocument.py Mon Mar 23 16:08:13 2026 +0100
+++ b/modules/edocument_ubl/edocument.py Thu Mar 26 08:14:45 2026 +0100
@@ -119,6 +119,26 @@
else:
return '389'
+ def allowed_additional_documents(self, specification=None):
+ allowed_mimetypes = self._allowed_addition_document_mimetypes(
+ specification)
+ for document in self.additional_documents:
+ if (document.get('code') != '130'
+ and allowed_mimetypes
+ and document.get('mimetype', '') not in allowed_mimetypes):
+ continue
+ yield document
+
+ @classmethod
+ def _allowed_addition_document_mimetypes(cls, specification=None):
+ if specification and specification.startswith('peppol'):
+ return {'application/pdf', 'image/png', 'image/jpeg', 'text/csv',
+ 'application/'
+ 'vnd.openxmlformats-officedocument.spreadsheetml.sheet',
+ 'application/vnd.oasis.opendocument.spreadsheet'}
+ else:
+ return {}
+
@property
def additional_documents(self):
pool = Pool()
diff -r 1862b6634dc3 -r af3cd28a3347
modules/edocument_ubl/template/2/CreditNote.xml
--- a/modules/edocument_ubl/template/2/CreditNote.xml Mon Mar 23 16:08:13
2026 +0100
+++ b/modules/edocument_ubl/template/2/CreditNote.xml Thu Mar 26 08:14:45
2026 +0100
@@ -30,7 +30,7 @@
<cbc:IssueDate>${origin_invoice.invoice_date}</cbc:IssueDate>
</cac:InvoiceDocumentReference>
</cac:BillingReference>
-<cac:AdditionalDocumentReference py:for="document in
this.additional_documents">
+<cac:AdditionalDocumentReference py:for="document in
this.allowed_additional_documents(specification)">
<cbc:ID>${document['id']}</cbc:ID>
<cbc:DocumentTypeCode
py:if="document.get('code')">${document['code']}</cbc:DocumentTypeCode>
<cbc:DocumentDescription
py:if="document.get('description')">${document['description']}</cbc:DocumentDescription>
diff -r 1862b6634dc3 -r af3cd28a3347
modules/edocument_ubl/template/2/Invoice.xml
--- a/modules/edocument_ubl/template/2/Invoice.xml Mon Mar 23 16:08:13
2026 +0100
+++ b/modules/edocument_ubl/template/2/Invoice.xml Thu Mar 26 08:14:45
2026 +0100
@@ -30,7 +30,7 @@
<cbc:IssueDate>${origin_invoice.invoice_date}</cbc:IssueDate>
</cac:InvoiceDocumentReference>
</cac:BillingReference>
-<cac:AdditionalDocumentReference py:for="document in
this.additional_documents">
+<cac:AdditionalDocumentReference py:for="document in
this.allowed_additional_documents(specification)">
<cbc:ID>${document['id']}</cbc:ID>
<cbc:DocumentTypeCode
py:if="document.get('code')">${document['code']}</cbc:DocumentTypeCode>
<cbc:DocumentDescription
py:if="document.get('description')">${document['description']}</cbc:DocumentDescription>