Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.Name_report">
<t t-call="report.Name_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><!--as reference for fixed positions-->

<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;">Adress Adress Adress</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>

<!--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>**
<!--page-break test-->


<div class="row" style="top:400px;  position: fixed;">

<!--TABLE-->
      <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>
like image 964
CripZ Avatar asked Sep 24 '15 08:09

CripZ


1 Answers

There are a few page break types that can be used for Qweb reports.

You can use one of these tags:

<p style="page-break-before:always;"> </p> (most reports use this type)

<p style="page-break-after:always"></p>

<div style="page-break-after: auto;"><span style="display: none;"> </span></div>

<p style="page-break-inside: avoid"></p>

<div style="page-break-inside: auto"></div>
like image 115
Jainik Patel Avatar answered Nov 11 '22 03:11

Jainik Patel