Skip to content

Commit

Permalink
[FIX] report: random disappearance of headers/footers
Browse files Browse the repository at this point in the history
This issue is related to the wkhtmltopdf issue
wkhtmltopdf/wkhtmltopdf#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
  • Loading branch information
beledouxdenis committed Apr 24, 2015
1 parent 296130f commit 3c61ee5
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion addons/report/views/layouts.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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()">
Expand Down

1 comment on commit 3c61ee5

@ericmachine88
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there any way to call the page number inside here

<t t-call="report.external_layout">
                <div class="page">
</div>
</t>

any help? thanks.

Please sign in to comment.