changeset a22984e8d532 in modules/account_invoice:default
details:
https://hg.tryton.org/modules/account_invoice?cmd=changeset&node=a22984e8d532
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
diffstat:
invoice.py | 4 +++-
1 files changed, 3 insertions(+), 1 deletions(-)
diffs (21 lines):
diff -r 4765d0e51844 -r a22984e8d532 invoice.py
--- a/invoice.py Tue Feb 01 11:31:06 2022 +0100
+++ b/invoice.py Thu Feb 03 22:25:56 2022 +0100
@@ -2874,7 +2874,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
@@ -2882,6 +2882,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)