Html report for invoice

Hi,

I want to send an html report as notification email with a pdf report attached when an invoice is posted. I already created the necessary reports and trigger.
Now the problem is, the custom _execute() method of account.invoice turns all data into bytes-like objects which is a problem for the html2text converter in the get_email() function of the html report.

File "/tryton/trytond/trytond/report/report.py", line 615, in get_email
    content_text = converter.handle(content)
  File "/tryton/lib/python3.13/site-packages/html2text/__init__.py", line 149, in handle
    self.feed(data)
    ~~~~~~~~~^^^^^^
  File "/tryton/lib/python3.13/site-packages/html2text/__init__.py", line 144, in feed
    data = data.replace("</' + 'script>", "</ignore>")
TypeError: a bytes-like object is required, not 'str'

What could I do here? Also, in general, if I have more than one report for my invoice, are they all cached separately? Because it seems like whichever is created first fills the cache.

Thanks for your help.

You should not use the standard invoice report for the HTML template. You should create a different report. This is because you will use two reports:

  1. For the text of the email (with HTML format)
  2. For the content of the invoice ( with PDF format)

If you already have two reports, make sure to use diferent report name for them to avoid the HTML content beeing executed by the account.invoice report.

Thank you so much for the quick help. Everything works now.

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.