[FIX] snailmail: Object of type bytes is not JSON serializable

Sending a letter resulted systematically in an error due to the insertion of the binary of the PDF in the JSON sent to IAP-services.

closes odoo/odoo#29880
This commit is contained in:
Antoine Prieels
2019-01-03 12:56:52 +00:00
parent c414873003
commit 62221bc3f9
+2 -2
View File
@@ -165,12 +165,12 @@ class SnailmailLetter(models.Model):
else:
# adding the web logo from the company for future possible customization
document.update({
'company_logo': letter.company_id.logo_web,
'company_logo': letter.company_id.logo_web.decode('utf-8'),
})
attachment = letter._fetch_attachment()
if attachment:
document.update({
'pdf_bin': route == 'print' and attachment.datas,
'pdf_bin': route == 'print' and attachment.datas.decode('utf-8'),
'pages': route == 'estimate' and self._count_pages_pdf(base64.b64decode(attachment.datas)),
})
else: