Skip to content
Snippets Groups Projects
Commit feb83c68 authored by qho's avatar qho Committed by Andrea Grazioso (agr-odoo)
Browse files

[FIX] base: fix "Original Bill" when file is image


1. Create an invoice and upload a picture file as the only attachment
2. Try to print "origin bill" for the invoice (From the invoice tree
view select one and click print > origin bill )

An error will raise "PIL.PdfParser.PdfFormatError: trailer end not found".
Fixing by using another BytesIO object as the output.

opw-2244625

closes odoo/odoo#50313

Signed-off-by: default avatarNicolas Martinelli (nim) <nim@odoo.com>
parent 5f35cbb7
No related branches found
No related tags found
No related merge requests found
......@@ -178,8 +178,9 @@ class IrActionsReport(models.Model):
if attachment.mimetype.startswith('image'):
stream = io.BytesIO(base64.b64decode(attachment.datas))
img = Image.open(stream)
img.convert("RGB").save(stream, format="pdf")
return stream
output_stream = io.BytesIO()
img.convert("RGB").save(output_stream, format="pdf")
return output_stream
return io.BytesIO(base64.decodestring(attachment.datas))
def retrieve_attachment(self, record):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment