Filter the MIME type of the additional documents in UBL allowed by the specification

Closes #14708
This commit is contained in:
Cédric Krier
2026-03-26 08:14:45 +01:00
parent 2f12db2751
commit 794b61b163
4 changed files with 23 additions and 2 deletions
+20
View File
@@ -119,6 +119,26 @@ class Invoice(Model):
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()