changeset b548a46aeded in modules/account_invoice:5.0
details:
https://hg.tryton.org/modules/account_invoice?cmd=changeset&node=b548a46aeded
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 7571bb17249d -r b548a46aeded invoice.py
--- a/invoice.py Fri Nov 05 00:19:15 2021 +0100
+++ b/invoice.py Thu Feb 03 22:25:56 2022 +0100
@@ -2425,7 +2425,7 @@
if invoice.invoice_report_cache:
return (
invoice.invoice_report_format,
- bytes(invoice.invoice_report_cache))
+ invoice.invoice_report_cache)
else:
result = super(InvoiceReport, cls)._execute(records, data, action)
# If the invoice is posted or paid and the report not saved in
@@ -2433,6 +2433,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)