İçereği Atla
Menü
This question has been flagged
1 Cevapla
1762 Görünümler

I want  to get only 10 lines of table records on every page of odoo qweb report.

Avatar
Vazgeç
Üretici

<table class="sth">
<thead>

<tr>
<th class="table_head" ><b>a</b></th>
<th class="table_head" ><b>b</b></th>
</tr>
</thead>
<tbody>
<t t-set="i" t-value="1" />

<tr t-foreach="o.ids" t-as="invoice_line">
<td class = "table_border">
<span t-esc="i"></span>
<t t-set="i" t-value="i+1" />
</td>
<td class = "table_border">
<span t-field="invoice_line.name" />
</td>
</tr>
</tbody>
</table>

Üretici

I have tried this but it is not working.
<t t-set="i" t-value="1"/>
<tr t-foreach="o.order_line" t-as="l">
<!--Check Condition and break-->
<td> <span t-esc="i"/></td>
<t t-set="i" t-value="i+1"/>
</tr>

Best Answer

Hi, you can try this

<t t-set="i"t-value="1" />
<tr t-foreach="o.order_line"t-as="l">
    <t t-if="i % 10 == 0">
        <p style="page-break-after:always;" />
    t>
    <td>
        <span t-esc="i" />
    td>
    <t t-set="i" t-value="i+1" />
tr>
Avatar
Vazgeç

Sorry for the typos but code blocks don't works properly, watch out for open tags.

Üretici

It is not working. It moves the whole table onto the next page

You can try splitting the recordset into chunks and create multiple tables on different pages.

```
<template id="report_template_test">
<t t-call="web.html_container">
<t t-call="web.internal_layout" t-lang="it_IT">
<div class="page">
<t t-set="chunk_size" t-value="10" />
<t t-set="chunks" t-value="[docs.ids[i:i+chunk_size] for i in range(0, len(docs), chunk_size)]" />
<t t-foreach="chunks" t-as="c">
<t t-call="report_table_test_template">
<t t-set="records" t-value="c" />
</t>
<p style="page-break-after:always;" />
</t>
</div>
</t>
</t>
</template>

<template id="report_table_test_template">
<!-- Create your table -->
<table class="table">
<thead>
<tr>
<th>#</th>
</tr>
</thead>
<tbody>
<t t-foreach="records" t-as="rec">
<tr>
<td>
<span t-esc="i" />
</td>
</tr>
</t>
</tbody>
</table>
</template>
```

Related Posts Cevaplar Görünümler Aktivite
3
Nis 25
1700
0
Mar 25
439
1
Şub 25
5166
3
Ara 24
1726
3
Ara 24
1713