Skip to Content
Odoo Menu
  • Sign in
  • Try it free
  • Apps
    Finance
    • Accounting
    • Invoicing
    • Expenses
    • Spreadsheet (BI)
    • Documents
    • Sign
    Sales
    • CRM
    • Sales
    • POS Shop
    • POS Restaurant
    • Subscriptions
    • Rental
    Websites
    • Website Builder
    • eCommerce
    • Blog
    • Forum
    • Live Chat
    • eLearning
    Supply Chain
    • Inventory
    • Manufacturing
    • PLM
    • Purchase
    • Maintenance
    • Quality
    Human Resources
    • Employees
    • Recruitment
    • Time Off
    • Appraisals
    • Referrals
    • Fleet
    Marketing
    • Social Marketing
    • Email Marketing
    • SMS Marketing
    • Events
    • Marketing Automation
    • Surveys
    Services
    • Project
    • Timesheets
    • Field Service
    • Helpdesk
    • Planning
    • Appointments
    Productivity
    • Discuss
    • Approvals
    • IoT
    • VoIP
    • Knowledge
    • WhatsApp
    Third party apps Odoo Studio Odoo Cloud Platform
  • Industries
    Retail
    • Book Store
    • Clothing Store
    • Furniture Store
    • Grocery Store
    • Hardware Store
    • Toy Store
    Food & Hospitality
    • Bar and Pub
    • Restaurant
    • Fast Food
    • Guest House
    • Beverage Distributor
    • Hotel
    Real Estate
    • Real Estate Agency
    • Architecture Firm
    • Construction
    • Estate Management
    • Gardening
    • Property Owner Association
    Consulting
    • Accounting Firm
    • Odoo Partner
    • Marketing Agency
    • Law firm
    • Talent Acquisition
    • Audit & Certification
    Manufacturing
    • Textile
    • Metal
    • Furnitures
    • Food
    • Brewery
    • Corporate Gifts
    Health & Fitness
    • Sports Club
    • Eyewear Store
    • Fitness Center
    • Wellness Practitioners
    • Pharmacy
    • Hair Salon
    Trades
    • Handyman
    • IT Hardware & Support
    • Solar Energy Systems
    • Shoe Maker
    • Cleaning Services
    • HVAC Services
    Others
    • Nonprofit Organization
    • Environmental Agency
    • Billboard Rental
    • Photography
    • Bike Leasing
    • Software Reseller
    Browse all Industries
  • Community
    Learn
    • Tutorials
    • Documentation
    • Certifications
    • Training
    • Blog
    • Podcast
    Empower Education
    • Education Program
    • Scale Up! Business Game
    • Visit Odoo
    Get the Software
    • Download
    • Compare Editions
    • Releases
    Collaborate
    • Github
    • Forum
    • Events
    • Translations
    • Become a Partner
    • Services for Partners
    • Register your Accounting Firm
    Get Services
    • Find a Partner
    • Find an Accountant
    • Meet an advisor
    • Implementation Services
    • Customer References
    • Support
    • Upgrades
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Get a demo
  • Pricing
  • Help

Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:

  • CRM
  • e-Commerce
  • Accounting
  • Inventory
  • PoS
  • Project
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
Tags (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Tags (View all)
odoo accounting v14 pos v15
About this forum
Help

Help on adding page-break on qweb reports: where to put the tag?

Subscribe

Get notified when there's activity on this post

This question has been flagged
qwebpagesodoo12.0
1 Reply
35794 Views
Avatar
Paulo Matos

Hello everyone.

I have the need to add a page-break on core Odoo invoice report report after a specific number of lines. Let's say 10 lines.

I have found several samples and information about which tags to use and how to use "if statements" for adding the page break, but unfortunately any of this samples help me because I do not know where to add the page-break tag.

I have found that the most used tags are:

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

Also found that one can use "if statements" inside the "for each" loops with the help of counter variables. For instance:

<t t-foreach="o.line_ids" t-as="line">
    <t t-if="line_index == 13">
        <div style="page-break-after: always;"><br/></div>
    </t>
</t>

Ok. Everything seems to be very easy, but all tests I have made were unsuccessful.

The core Odoo invoice report already have the "<t t-foreach...":

The core report (part of it):

<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-200 font-weight-bold o_line_section' if line.display_type == 'line_section' else 'font-italic o_line_note' if line.display_type == 'line_note' else ''">
    <t t-if="not line.display_type" name="account_invoice_line_accountable">
        <td name="account_invoice_line_name"><span t-field="line.name"/></td>
        <td class="d-none"><span t-field="line.origin"/></td>
        <td class="text-right">
            <span t-field="line.quantity"/>
            <span t-field="line.uom_id" groups="uom.group_uom"/>
        </td>
        <td t-attf-class="text-right {{ 'd-none d-md-table-cell' if report_type == 'html' else '' }}">
            <span t-field="line.price_unit"/>
        </td>
        ...more code here
</t> #End of for loop here

On my understanding, Qweb starts the loop and for every line (record) it finds, it will add the <tr's> and <td's> based on table structure.

So, based on that, I have tried to use qweb variables and an if statement to increase a counter, and if the 10th value is reached, qweb adds a page break.

So I have tried:


<t t-set="counter" t-value="0" />

<t t-foreach="o.invoice_line_ids" t-as="line">

    <t t-if="counter == 10">
        <p style="page-break-before:always;"> </p>
    </t>
    <t t-set="counter" t-value="counter + 1" />
    
....here starts the core Odoo report data
    <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-200 font-weight-bold o_line_section' if line.display_type == 'line_section' else 'font-italic o_line_note' if line.display_type == 'line_note' else ''">
    <t t-if="not line.display_type" name="account_invoice_line_accountable">
        <td name="account_invoice_line_name"><span t-field="line.name"/></td>
        <td class="d-none"><span t-field="line.origin"/></td>
        <td class="text-right">
            <span t-field="line.quantity"/>
            <span t-field="line.uom_id" groups="uom.group_uom"/>
        </td>
        <td t-attf-class="text-right {{ 'd-none d-md-table-cell' if report_type == 'html' else '' }}">
            <span t-field="line.price_unit"/>
        </td>
        ...more code here
</t> #End of for loop here

Using this approach it does not work and it adds a page break at the first page and the full report content (table header, rows and columns) goes to the second page.

Also tried to add the full code starting from the "foreach" inside the if condition and using this approach, I can only see the table header and cannot see the rows and columns...

Can anyone please send me a sample on where should I put this if condition in order to get the desired result? Break the page after the 10th invoice line?

Thank you all very much in advance

Best regards

PM


1
Avatar
Discard
Jornald

I have same problem.How did you solve this?

Simon in Canada

Any luck in finding a solution for this?

Avatar
Régis GEROMEGNACE
Best Answer

Hello,

You must reinitialize your counter I think like this or use modulo if possible in qweb.

 

<t t-if="counter == 10">
<p style="page-break-before:always;"> </p>

<t t-set="counter" t-value="0"/>
</t>

<t t-set="counter" t-value="counter + 1" />

Regards,

4
Avatar
Discard
Enjoying the discussion? Don't just read, join in!

Create an account today to enjoy exclusive features and engage with our awesome community!

Sign up
Related Posts Replies Views Activity
Replace the print option on top of form with a Print button. How can I achieve that? Solved
qweb reporting odoo12.0
Avatar
Avatar
1
Feb 19
10579
Print payslip is not generating all pages - Working randomly
qweb payroll payslip odoo12.0
Avatar
0
May 19
2854
Expected singleton: hr.emp.travel.location(62, 63)
odoo12.0
Avatar
Avatar
Avatar
2
Oct 25
2083
Odoo 18: Display image from char field containing url in qweb form
qweb
Avatar
Avatar
1
Jul 25
3103
PDF Export Option for QWeb Reports in odoo 17.0
qweb
Avatar
Avatar
1
May 25
4068
Community
  • Tutorials
  • Documentation
  • Forum
Open Source
  • Download
  • Github
  • Runbot
  • Translations
Services
  • Odoo.sh Hosting
  • Support
  • Upgrade
  • Custom Developments
  • Education
  • Find an Accountant
  • Find a Partner
  • Become a Partner
About us
  • Our company
  • Brand Assets
  • Contact us
  • Jobs
  • Events
  • Podcast
  • Blog
  • Customers
  • Legal • Privacy
  • Security
الْعَرَبيّة Català 简体中文 繁體中文 (台灣) Čeština Dansk Nederlands English Suomi Français Deutsch हिंदी Bahasa Indonesia Italiano 日本語 한국어 (KR) Lietuvių kalba Język polski Português (BR) română русский язык Slovenský jazyk slovenščina Español (América Latina) Español ภาษาไทย Türkçe українська Tiếng Việt

Odoo is a suite of open source business apps that cover all your company needs: CRM, eCommerce, accounting, inventory, point of sale, project management, etc.

Odoo's unique value proposition is to be at the same time very easy to use and fully integrated.

Website made with

Odoo Experience on YouTube

1. Use the live chat to ask your questions.
2. The operator answers within a few minutes.

Live support on Youtube
Watch now