Skip to Content
Menu
This question has been flagged
1 Odpoveď
10225 Zobrazenia

I would like to control the Page numbers being displayed in the footer of the report.

Standard Paging concept allows to print the page numbers in this fashion "Page 1 / 1" or "Page 1 / 2" etc.

I have no problem with the above one. However if the total number of Page in the report itself is 1, then I would prefer not to print any page number. In other words I wish to print page number only if the pages are more than One.

So is there any value, that  I could find out total number of pages, I understand that Odoo uses a class called "topage" defined in the <span>, which prints the total number of page number, but am unlikely to extract data from it to utilise for my need.


Avatar
Zrušiť
Best Answer

You could override report.minimal_layout to introduce a new class which blocks / hides when the total pages are greater than 1.

<template id="report.minimal_layout">

<t t-raw="'&lt;base href=%s&gt;' % base_url"/>

&lt;!DOCTYPE html&gt;

<html style="height: 0;">

<head>

<link href="/report/static/src/css/reset.min.css" rel="stylesheet"/>

<link href="/web/static/lib/bootstrap/css/bootstrap.css" rel="stylesheet"/>

<link href="/website/static/src/css/website.css" rel="stylesheet"/>

<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>

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]];

}

var operations = {

'single-page': function (elt)

{

elt.style.display = (vars.topage >1) ? "block" : "none";

},

};

for (var klass in operations)

{

var y = document.getElementsByClassName(klass);

for (var j=0; j&lt;y.length; ++j)

operations[klass](y[j]);

}

}

</script>

</t>

</head>

<body class="container" onload="subst()">

<t t-raw="body"/>

</body>

</html>

</template>


Then, you can override the external_layout_footer as well:

<ul class="list-inline single-page">

<li>Page:</li>

<li><span class="page"/></li>

<li>/</li>

<li><span class="topage"/></li>

</ul>


Now, since we included the single-page class, that class will only be shown if the topage value is greater than 1.

Let me know if you need more help on this.


Avatar
Zrušiť
Related Posts Replies Zobrazenia Aktivita
0
jan 24
1524
0
jan 24
1228
0
feb 22
2442
2
sep 16
10039
2
dec 15
5173