changeset 79aec7c017d8 in modules/account_invoice:6.0
details:
https://hg.tryton.org/modules/account_invoice?cmd=changeset&node=79aec7c017d8
description:
Convert report into bytes before storing
If the invoice report has a text output, we must encode it as utf-8
before
storing it.
And we do not need to convert to bytes the data read because Binary
field is
already doing that.
issue10937
review376581002
(grafted from a22984e8d5324c2ee018fa9b91e89bb5cefefd4c)
diffstat:
invoice.py | 4 +++-
1 files changed, 3 insertions(+), 1 deletions(-)
diffs (21 lines):
diff -r a877caf351d0 -r 79aec7c017d8 invoice.py
--- a/invoice.py Sun Jan 30 01:19:23 2022 +0100
+++ b/invoice.py Thu Feb 03 22:25:56 2022 +0100
@@ -2769,7 +2769,7 @@
if invoice.invoice_report_cache:
return (
invoice.invoice_report_format,
- bytes(invoice.invoice_report_cache))
+ invoice.invoice_report_cache)
else:
result = super()._execute(records, header, data, action)
# If the invoice is posted or paid and the report not saved in
@@ -2777,6 +2777,8 @@
# now in invoice_report_cache
if invoice.state in {'posted', 'paid'} and invoice.type == 'out':
format_, data = result
+ if isinstance(data, str):
+ data = bytes(data, 'utf-8')
invoice.invoice_report_format = format_
invoice.invoice_report_cache = \
Invoice.invoice_report_cache.cast(data)