Skip to Content
Menu
This question has been flagged
1 Reply
6928 Views

I am using version 12, and let's say i have 20 products in invoice and it showed all in one page. 

I would like to limit it to 10 products only per page, and the rest will be showed in the next page. I edited report_invoice_document as instructed \here, especially in foreach but entire table is breaking into next page instead.

Edit : Sorry, the anchor link doesn't referring to where it should be. Here's the link :
\https://www.odoo.com/forum/help-1/question/print-invoice-with-10-lines-per-pages-104742​

Here is the "clean code" (before I edit it) :

<tbody class="invoice_tbody">
<t t-set="current_subtotal" t-value="0"/>
<t t-foreach="o.invoice_line_ids" t-as="line">

<t t-set="current_subtotal" t-value="current_subtotal + line.price_subtotal" groups="account.group_show_line_subtotals_tax_excluded"/>
<t t-set="current_subtotal" t-value="current_subtotal + line.price_total" groups="account.group_show_line_subtotals_tax_included"/>

<tr t-att-class="'bg-100 font-weight-bold' if line.display_type == 'line_section' else 'font-italic' if line.display_type == 'line_note' else ''" style="font-size:14px;">
<t t-if="not line.display_type" name="account_invoice_line_accountable">
<td class="text-center">
<span t-esc="line_index + 1"/>
</td>
<td class="text-center">
<span t-field="line.quantity"/>
</td>
<td class="text-center">
<span t-field="line.uom_id" groups="uom.group_uom"/>
</td>
<td name="account_invoice_line_name"><span t-field="line.name"/></td>
<td class="d-none"><span t-field="line.origin"/></td>

<td t-attf-class="text-right {{ 'd-none d-md-table-cell' if report_type == 'html' else '' }}">
<span t-field="line.price_unit" t-options="{"widget": "monetary", "display_currency": o.currency_id}"/>
</td>
<td t-if="display_discount" t-attf-class="text-right {{ 'd-none d-md-table-cell' if report_type == 'html' else '' }}">
<span t-field="line.discount"/>
</td>
<td class="text-right">
<span t-field="line.price_subtotal" groups="account.group_show_line_subtotals_tax_excluded"/>
<span t-field="line.price_total" groups="account.group_show_line_subtotals_tax_included"/>
</td>
</t>
<t t-if="line.display_type == 'line_section'">
<td t-att-colspan="colspan">
<span t-field="line.name"/>
</td>
<t t-set="current_section" t-value="line"/>
<t t-set="current_subtotal" t-value="0"/>
</t>
<t t-if="line.display_type == 'line_note'">
<td t-att-colspan="colspan">
<span t-field="line.name"/>
</td>
</t>
</tr>

<t t-if="current_section and (line_last or o.invoice_line_ids[line_index+1].display_type == 'line_section')">
<tr class="is-subtotal text-right" style="font-size:14px;">
<td t-att-colspan="colspan">
<strong class="mr16">Subtotal</strong>
<span t-esc="current_subtotal" t-options="{"widget": "monetary", "display_currency": o.currency_id}"/>
</td>
</tr>
</t>
</t>
</tbody>


Every suggestion and help is appreciated,

Thanks You!

Avatar
Discard
Best Answer

Hello, you can add at the end

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

Avatar
Discard
Author

Hi GiusyG,

Thank you for replying. I put code above but unfortunately still not working.

Or did i put it in the wrong place? which "end" you are referring to?

I always insert it after the closing div of the "page" class and it works :-)

Author

yes it worked but i mean it's not splitting the table into a new page.

Instead, it's page breaking the entire table to the new ones.

Do you have any other ways possible?

you can insert the page break as in this example:

<t t-foreach="docs" t-as="o">

<div class="page">

<div class="oe_structure"/>

<t t-foreach="o.agent_ids" t-as="agent">

<t t-if="agent.partner_ids">

<!-- Break page for new doc -->

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

<h2>

<span>REPORT COMMISSIONI</span>

</h2>

.....

Create for each agent a new page with this title if it finds the new agent goes to the new page.

Related Posts Replies Views Activity
3
Jan 20
6977
1
Mar 17
2409
1
Feb 17
8341
2
Feb 24
5381
2
Oct 22
6258