[FIX] website_sale_digital: fix download attachement Py3
Before this commit, an Error 500 was thrown to the user upon downloading an attachement It was due to two things: - wrong return on a function - the filename that http.send_file takes shouldn't be a string, but bytes in Py3
This commit is contained in:
@@ -101,6 +101,6 @@ class WebsiteSaleDigital(CustomerPortal):
|
||||
return request.not_found()
|
||||
elif attachment["datas"]:
|
||||
data = io.BytesIO(base64.standard_b64decode(attachment["datas"]))
|
||||
return http.send_file(data, filename=attachment['name'].encode('utf-8'), as_attachment=True)
|
||||
return http.send_file(data, filename=attachment['name'], as_attachment=True)
|
||||
else:
|
||||
return request.not_found()
|
||||
|
||||
@@ -25,4 +25,4 @@ class AccountInvoiceLine(models.Model):
|
||||
|
||||
# I only want product_ids, but search_read insists in giving me a list of
|
||||
# (product_id: <id>, name: <product code> <template_name> <attributes>)
|
||||
return purchases.mapped('product_id').ids
|
||||
return [line['product_id'][0] for line in purchases]
|
||||
|
||||
Reference in New Issue
Block a user