This question has been flagged
1 Reply
4006 Views

I'm using Odoo 14 community. I have a few custom reports. In this report while I print, the header or footer is missing in some prints, sometimes the header or footer comes and sometimes not. I updated the latest addons and downgraded the wkhtmltopdf 0\.12\.1\.5\ to\ wkhtmltopdf\ 0.12.1.3.

Avatar
Discard

did you solve this problem?

may be missing report.url issue in system parameter ?
https://www.youtube.com/watch?v=lC9p_QJUW1Q

Best Answer

We also faced the same issue at random times, the qweb report  header content is shown blank. 

Even after trying out various options like adding report.url and other general solutions, it still gave the same blank header at frequent times. 

After doing an extensive code walk through we found that report header is loading below java script through the file report_templates.xml.

function subst() {...} 

Further debugging lead us to the ir_actions_report.py where it controls the addition of this script in the header and footer html. 

header = layout._render(dict(subst=True, body=lxml.html.tostring(header_node), base_url=base_url))

We gave this subst=False in order not to generate the java script content and it did not load the script as expected. 

How ever the issue still persisted and it gave us the though that, it is indeed the java script loading issue at wkhtmltopdf module. 

So we went through the wkhtmltopdf documentation and identified that there is a parameter '--javascript-delay' which can be used to control the loading of javascript.

Hence we added below line of code in ir_action_report.py file  to add this parameter to the wkhtml argument list. 

command_args.extend(['--javascript-delay', str(1000)])

This gave us the perfect solution for this issue. 

But we are curious to know why odoo load the above java script in the report html as it simply take the back up of the header text and append it back. 

Please check and let me know if this works out for your case


Avatar
Discard