changeset 59a2c5a5f428 in modules/account_invoice:6.2
details: 
https://hg.tryton.org/modules/account_invoice?cmd=changeset&node=59a2c5a5f428
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 01b9a0d65df8 -r 59a2c5a5f428 invoice.py
--- a/invoice.py        Sun Jan 30 01:19:23 2022 +0100
+++ b/invoice.py        Thu Feb 03 22:25:56 2022 +0100
@@ -2836,7 +2836,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
@@ -2844,6 +2844,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)

Reply via email to