[FIX] account: prevent error will uploading empty text attachment in invoice
When the user uploads an empty text file in the invoice it generates an attribute error with 'bool' object getting no attribute 'startswith'. Steps to produce:- - Install 'account' - Go to 'Invoice' - Create an invoice with an empty .txt attachment in the chatter section - Click 'Send' - Traceback is generated Applying this commit will fix this issue. sentry-4187919992 closes odoo/odoo#122103 X-original-commit: 7a12da836fa9926e12b15484aad77224cb75d3a3 Signed-off-by: William André (wan) <wan@odoo.com>
This commit is contained in:
@@ -100,7 +100,7 @@ class IrAttachment(models.Model):
|
||||
# XML attachments received by mail have a 'text/plain' mimetype (cfr. context key:
|
||||
# 'attachments_mime_plainxml'). Therefore, if content start with '<?xml', or if the filename ends with
|
||||
# '.xml', it is considered as XML.
|
||||
is_text_plain_xml = 'text/plain' in attachment.mimetype and (attachment.raw.startswith(b'<?xml') or attachment.name.endswith('.xml'))
|
||||
is_text_plain_xml = 'text/plain' in attachment.mimetype and (attachment.raw and attachment.raw.startswith(b'<?xml') or attachment.name.endswith('.xml'))
|
||||
return attachment.mimetype.endswith('/xml') or is_text_plain_xml
|
||||
|
||||
return [
|
||||
|
||||
Reference in New Issue
Block a user