[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:
Lucas Perais (lpe)
2017-09-29 10:47:37 +02:00
parent 0f3b2859a9
commit ea2650aa79
2 changed files with 2 additions and 2 deletions
@@ -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]