3
votes

Odoo v8 uses Qweb and we need to print the terms and conditions of sale on the last page of the invoice.

As I understand we need to test that it is the last page of the report and print some static HTML on this page.

Does anyone know how to test the last page and remove the header and footer from it to achieve what I am trying.

Or even another way of doing it.

1

1 Answers

0
votes

In last version of odoo, version 8 (or saas-6), to enable special class names to do special things (as for instance a 'last-page' class name to trigger visibility), you should only modify report module, in static/src/js/subst.js, and add this code to the subst function:

var operations = {
    'last-page': function (elt) { elt.style.visibility = (vars.page === vars.topage) ? "visible" : "hidden"; },
};

for (var klass in operations) {
    var y = document.getElementsByClassName(klass);
    for (var j=0; j<y.length; ++j) operations[klass](y[j]);
}

In the QWEB ir.ui.views used by your report, you can then add anywhere (header, body, footer), code with:

<div class="last-page">
    My content only displayed if on last page.
<div>

EDIT: An OpenERP/Odoo addon to add this magic class last-page easily was implemented as an example: https://github.com/0k/report_extended