Skip to Content
Menu
This question has been flagged
1 Atsakyti
1750 Rodiniai

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

Portretas
Atmesti
Autorius

<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>

Autorius

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>
Portretas
Atmesti

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

Autorius

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 Replies Rodiniai Veikla
3
bal. 25
1678
0
kov. 25
429
1
vas. 25
5131
3
gruod. 24
1718
3
gruod. 24
1682