Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

2

How to count pages in webkit report (not in header/footer)?

By
Isnogood
on 8/15/13, 10:57 AM 2,436 views

Hi,

I want to achieve report page count in .mako file of webkit reports, as it is in standard webkit footer (in xml). Following footer example, I have tried this in .mako (output is "Number of pages: undefined"):

<html>
<head>
<script>
    function subst() {
    var vars={};
    var x=document.location.search.substring(1).split('&');
    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<y.length; ++j) y[j].textContent = vars[x[i]];
        }
    }
</script>
<style type="text/css">
${css}
</style>
</head>
<body onload="subst()">
%for o in objects:
<p>Number of pages: <span class="topage"/> </p>
%endfor
</body>
</html>

Many thanks in advance!

1
Paul Catinean
On 9/18/13, 7:56 AM

To my knowledge this is not possible since the header and footer get parsed separately from the mako through a different procedure.The header and footer have access to this information since they get parsed at the initial stages, after which mako is used and concatenated

I really hope I am wrong but my investigations revealed this so far

0
Matteo Boscolo
On 9/19/13, 12:54 PM

webkir report use the mako template, the mako template allows you to use inside a loop the magic variable loop

Page ${loop.index+1} of ${len(objects)}

look at: --docs.makotemplates.org/en/latest/runtime.html#mako.runtime.LoopContext

for more datails

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

Asked: 8/15/13, 10:57 AM
Seen: 2436 times
Last updated: 3/16/15, 8:10 AM