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.

1

How to include a 'page break' / second page in custom report (pdf)?

By
Philipp Becker
on 9/24/15, 4:21 AM 1,879 views

I created a new report from scratch using this guide: http://odoo.guide/report-design-workshop/

My Problem:
If I have a lot of products on my report the last part including total amount etc. is not shown. I would like to have a kind of page break or at least a second pdf page.

Note: If I use the basic odoo report I have a second page in the pdf but it is shown as this: 
http://fs5.directupload.net/images/150924/bf9lsx6u.jpg

Any other ideas are welcome!

Edit: In the basic report using the page-break tag works realy fine but it didnt affect my own report design at all.

My Code trying to use the page-break tag:

account.Name_report

<?xml version="1.0"?>

<t t-name="account.HanDS_report">
<t t-call="report.HanDS_layout">
<t t-foreach="docs" t-as="o"> <!-- this makes the context model data accessible throughout the variable "o" -->

<div class="page">



<div style="color:white">.</div>

<img src="/document/static/img/Briefpapier_rechnung.svg" style="position: fixed; left:-20px;top:0px;z-index:-100"/>

<div style=" color: white;
font-size: 20px;
z-index: 1;
position: fixed;
left: 390px;
top: 36px;
font-size: 38px;">Rechnung
</div>

<!--Adresse-->
<div style="color: black;
font-size: -1px;
z-index: 1;
position: fixed;
top: 138px;
left: 60px;
font-size: 12px;">
<span style="text-decoration: underline;">HanDS GmbH, Wendenstr. 377, 20537 Hamburg</span><br/>
<address t-field="o.partner_id" t-field-options="{&quot;widget&quot;: &quot;contact&quot;, &quot;fields&quot;: [&quot;address&quot;, &quot;name&quot;], &quot;no_marker&quot;: true}"/><br/>
</div>

<!--Kunden Nr/Datum-->
<div style="color: black;
font-size: -1px;
z-index: 1;
position: fixed;
left: 450px;
top: 255px;
font-size: 12px;">
<span>Referenz Nr.:</span><br/>
<span>Datum:</span>
</div>

<div style="color: black;
font-size: -1px;
z-index: 1;
position: fixed;
top: 255px;
right: 0px;
font-size: 12px;
text-align: right;">
<span t-field="o.reference"/><br/>
<span t-field="o.date_invoice"></span>
</div>

<h2>

</h2>

<!--Rechnung Nr.-->
<div style="color: black;
font-size: 20px;
z-index: 1;
position: fixed;
left: 0px;
top: 335px;
font-size: 16px;
font-weight: bold;">

<span t-if="o.type == 'out_invoice' and (o.state == 'open' or o.state == 'paid')">Rechnung</span>
<span t-if="o.type == 'out_invoice' and o.state == 'proforma2'">PRO-FORMA</span>
<span t-if="o.type == 'out_invoice' and o.state == 'draft'">Rechnungsentwurf</span>
<span t-if="o.type == 'out_invoice' and o.state == 'cancel'">abgebrochene Rechnung</span>
<span t-if="o.type == 'out_refund'">Erstattung</span>
<span t-if="o.type == 'in_refund'">Lieferant Rückerstattung</span>
<span t-if="o.type == 'in_invoice'">Lieferant Rechnung</span>
<span t-field="o.number"/>
</div>
<p style="page-break-before:always;"> </p>
<div class="row" style="top:400px; position: fixed;">
<!--TABLE TEST-->

<table class="table table-condensed">
<thead>
<tr>
<th>Beschreibung</th>
<th>Menge</th>
<th class="text-right">Einzelpreis EUR</th>
<th class="text-right" groups="sale.group_discount_per_so_line">Rabatt (%)</th>
<th class="text-right">Steuern</th>
<th class="text-center">Gesamtpreis EUR</th>
</tr>
</thead>
<tbody class="invoice_tbody">
<tr t-foreach="o.invoice_line" t-as="l">
<td><span t-field="l.name"/></td>
<td>
<span t-field="l.quantity"/>
<span t-field="l.uos_id" groups="product.group_uom"/>
</td>
<td class="text-right">
<span t-field="l.price_unit"/>
</td>
<td class="text-right" groups="sale.group_discount_per_so_line"><span t-field="l.discount"/></td>
<td class="text-right">
<span t-esc="', '.join(map(lambda x: x.name, l.invoice_line_tax_id))"/>
</td>
<td class="text-right">
<span t-field="l.price_subtotal" t-field-options="{&quot;widget&quot;: &quot;monetary&quot;, &quot;display_currency&quot;: &quot;o.currency_id&quot;}"/>
</td>
</tr>
</tbody>
</table>

<div class="row">
<div class="col-xs-4 pull-right">
<table class="table table-condensed">
<tr class="border-black">
<td><strong>Gesamt Netto</strong></td>
<td class="text-right">
<span t-field="o.amount_untaxed" t-field-options="{&quot;widget&quot;: &quot;monetary&quot;, &quot;display_currency&quot;: &quot;o.currency_id&quot;}"/>
</td>
</tr>
<tr>
<td>Steuern</td>
<td class="text-right">
<span t-field="o.amount_tax" t-field-options="{&quot;widget&quot;: &quot;monetary&quot;, &quot;display_currency&quot;: &quot;o.currency_id&quot;}"/>
</td>
</tr>
<tr class="border-black">
<td><strong>Gesamtbetrag</strong></td>
<td class="text-right">
<span t-field="o.amount_total" t-field-options="{&quot;widget&quot;: &quot;monetary&quot;, &quot;display_currency&quot;: &quot;o.currency_id&quot;}"/>
</td>
</tr>
</table>
</div>
</div>

<div class="row" t-if="o.tax_line">
<div class="col-xs-6">
<table class="table table-condensed">
<thead>
<tr>
<th>Steuern</th>
<th class="text-right">Steuergrundbetrag</th>
<th class="text-right">Betrag</th>
</tr>
</thead>
<tbody>
<tr t-foreach="o.tax_line" t-as="t">
<td><span t-field="t.name"/></td>
<td class="text-right">
<span t-field="t.base" t-field-options="{&quot;widget&quot;: &quot;monetary&quot;, &quot;display_currency&quot;: &quot;o.currency_id&quot;}"/>
</td>
<td class="text-right">
<span t-field="t.amount" t-field-options="{&quot;widget&quot;: &quot;monetary&quot;, &quot;display_currency&quot;: &quot;o.currency_id&quot;}"/>
</td>
</tr>
</tbody>
</table>

<span>Zahlbar innerhalb 14 Tagen ohne Abzug</span>
</div>
</div>
</div>





</div>
</t>
</t>
</t>
2

Axel Mendoza

--Axel Mendoza--
10238
| 7 7 8
Camaguey, Cuba
--Axel Mendoza--

DevOps - Full stack - Software Architect - Developer - Technology Integrator

I could help you to develop anything and solve complex problems based on technologies, integrations and tricky stuffs mostly in Python with OpenERP/Odoo, Zato, Django and many others frameworks programming languages and technologies.

I offers consulting services to anyone with an unanswered questions or needs for customizations. Think about it, maybe it's better to have an expert to solve your issues and projects than having a full time employee trying to understand what to do an how

Reach me at aekroft@gmail.com

Axel Mendoza
On 9/24/15, 5:56 AM

You could do a page break in qweb using something like this:

<div style="page-break-before: always;">
...
</div>

use page-break-before or page-break-after and you could do a conditional break wrapping that snippet in a "t-if" statement

Thank you, that work realy fine for the basic odoo report. But unfortunately that didnt affect my own report design at all. Any Solution where I config a second pdf page because my own report always shows only 1 page.

Philipp Becker
on 9/25/15, 10:19 AM

With that way I force wkhtml2pdf to change the page to display the next content, what did you mean with your own report design?

Axel Mendoza
on 9/25/15, 10:30 AM

I used this guide to build a own report and I only have 1 pdf page: http://odoo.guide/report-design-workshop/

Philipp Becker
on 9/28/15, 4:40 AM

I don't see how the html snippet provided doesn't affect your report layout. When you put on your report architecture you will cause a page break, you just need to define where. For example you can check the number of lines per page that you wanna show to insert the

before the next line to cause it to go for the next page. Test it and share the results
Axel Mendoza
on 9/28/15, 10:30 AM

I used

to test it. As I said it works on basic report. I added my code to the original question.
Philipp Becker
on 9/29/15, 4:48 AM

* p style="page-break-before:always;"

Philipp Becker
on 9/29/15, 4:49 AM

could you post the content of report.HanDS_layout too??

Axel Mendoza
on 9/29/15, 5:02 AM

could you test it by put some content inside of the
*p style="page-break-before:always;"*

Axel Mendoza
on 9/29/15, 5:08 AM

It works! I had to put content inside the

-tag. Thank you very much!

Philipp Becker
on 9/30/15, 5:56 AM

Now I have a new Problem, I always have at least 2 pages now? But I only need one page if there arent many products on the report. Any Solution?

Philipp Becker
on 10/8/15, 4:15 AM

Solution: I used style="page-break-before:auto" and set the position of the table div to position:relative;

Philipp Becker
on 10/9/15, 4:32 AM

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: 9/24/15, 4:21 AM
Seen: 1879 times
Last updated: 8/10/16, 7:41 AM