[FIX] report: random disappearance of headers/footers

This issue is related to the wkhtmltopdf issue
https://github.com/wkhtmltopdf/wkhtmltopdf/issues/2083

It seems there is a race condition in the Javascript file
loading in wkhtmltopdf 0.12.x.

The subst.js file put in the header/footer of reports
was not always loaded when the page was being rendered,
leading to the crash of the onload="subst()" attr in
the body node, leading to the non-rendering
of the header/footer.

Replacing the script file by its content solves
the issue.

Increasing the --javascript-delay of the wkhtmltopdf
executable (e.g. 1000 ms instead of 200 ms,
the default value) seems to solve the problem
as well, but will lead to obvious performance issues.

We therefore choose to put the javascript code inline,
as a workaround,
the time the issue is solved in wkhtmltopdf, at least.

closes #3047,#5548,#6207
opw-633161
This commit is contained in:
Denis Ledoux 2015-04-24 15:44:26 +02:00
parent 296130fbd3
commit 3c61ee5c68
1 changed files with 16 additions and 1 deletions

View File

@ -152,7 +152,22 @@
<link href="/web/static/lib/fontawesome/css/font-awesome.css" rel="stylesheet"/>
<style type='text/css'><t t-raw="css"/></style>
<t t-if="subst is True">
<script src='/report/static/src/js/subst.js'></script>
<script>
function subst() {
var vars = {};
var x = document.location.search.substring(1).split('&amp;');
for (var i in x) {
var z = x[i].split('=', 2);
vars[z[0]] = unescape(z[1]);
}
var x=['frompage', 'topage', 'page', 'webpage', 'section', 'subsection', 'subsubsection'];
for (var i in x) {
var y = document.getElementsByClassName(x[i]);
for (var j=0; j&lt;y.length; ++j)
y[j].textContent = vars[x[i]];
}
}
</script>
</t>
</head>
<body class="container" onload="subst()">