Skip to Content
Menu
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
To pytanie dostało ostrzeżenie
1 Odpowiedz
10218 Widoki

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.


Awatar
Odrzuć
Najlepsza odpowiedź

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.


Awatar
Odrzuć
Powiązane posty Odpowiedzi Widoki Czynność
0
sty 24
1521
0
sty 24
1220
0
lut 22
2440
2
wrz 16
10031
2
gru 15
5170