[FIX] account_facturx: process pdf with .PDF extensions

In fact, "not filename.endswith('.pdf')" does not
"Check if the attachment is a pdf".
Some pdf files have filenames with a pdf extension, but .PDF, .Pdf
work generally just as well, and it's also possible to live without a file
extension.
In any case, it doesn't prevent from crashes because of corrupted files,
or files that are not pdf files but have the extension.

opw 2075933

X-original-commit: 3f63447d8f25f6ff8a4d9951a74db069d41332f3
This commit is contained in:
Nans Lefebvre
2019-10-10 14:28:09 +00:00
committed by fw-bot
parent 381fa5abdd
commit 66a2ca0591
@@ -254,12 +254,6 @@ class AccountMove(models.Model):
def _get_attachment_content(attachment):
# Handle both _Attachment namedtuple in mail.thread or ir.attachment.
return hasattr(attachment, 'content') and getattr(attachment, 'content') or base64.b64decode(attachment.datas)
filename = _get_attachment_filename(attachment)
# Check if the attachment is a pdf.
if not filename.endswith('.pdf'):
return
content = _get_attachment_content(attachment)
with io.BytesIO(content) as buffer: