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

How to keep footer always at the bottom of the very last page in QWeb PDF report

Subscribe

Get notified when there's activity on this post

This question has been flagged
salesdebugpdf
2 Replies
1241 Views
Avatar
jasson

I am customizing a QWeb PDF report in Odoo17 (Delivery Slip).

My problem: the footer does not stay at the bottom of the page.

  • If I use margin-top, it works but it is hard-coded and breaks when content is long/short.
  • If I use position:absolute; bottom:0, with relative to the page, the footer sticks to the bottom of only the first page.
  • I tried using position : fixed, bottom:0, the footer disappears
  • I also tried using odoo built in class footer and the footer disappears

Note: The content is dynamically rendered by the one2many tree inside delivery order


Here's my simplified code:
<div class="page">

    <div class="container">

        <!-- report content / table -->

    </div>


    <div class="custom-footer">

        <p>Notes: ...</p>

        <p>Signature: ...</p>

    </footer>

</div>


0
Avatar
Discard
Avatar
Cybrosys Techno Solutions Pvt.Ltd
Best Answer

Hi,


To print the header/footer only on the first/last page, you can use the OCA module.

* https://odoo-community.org/shop/report-qweb-element-page-visibility-2192

After installing the module, use the first-page or last-page class.

Header


<div class="header">

    <div class="first-page">

        <div class="row">

            <img t-if="company.custom_report_header"

                 t-att-src="image_data_uri(company.custom_report_header)"

                 alt="Logo" width="100%"/>

        </div>

    </div>

</div>



Footer.


<div class="footer o_standard_footer">

    <div class="last-page">

        <div style="width: 100%;">

             <img t-if="company.custom_report_footer"

             t-att-src="image_data_uri(company.custom_report_footer)"

             alt="Logo" width="100%"/>

          </div>


      </div

</div>



Hope it helps

0
Avatar
Discard
Avatar
Nathanael Lee
Best Answer

Hi Jason

I was struggling with this issue too for a long time, and have not found a really clean solution. Currently I am using the following workaround:

- Create a helper report with exactly the same content (just duplicate the existing one)
- Write a method on the report model, which renders the helper report, and then analyzes the pdf and returns the page count
- Use the method in the final report, it will output the page count of the report, with this you can then dynamically set the position absolute top of the footer. 

Below are the code examples. 

Relevant Parts of the XML in the final report (only copied the relevant lines here)

<t t-set="page_count_page_2" t-value="o.get_report_page_count('custom_module.pdf_quote_report_helper_template')"/>
<t t-set="footer_top" t-value="1048.3 if page_count_page_2 == 2 else 670.6"/>
<!-- Footer is positioned dynamically according to page content using footer_top -->
<div t-att-style="'position: absolute; left: 0mm; width: 292mm; height: 85mm; background: #122439; top: %.1fmm;' % footer_top">



Render Report Page Count: 

def get_report_page_count(self, report_name):
"""
This method is used to render a helper report inside the sale quotation report and returns
its page count. This is needed for the dynamic positioning of page 2 footer, because the
footer should only be shown at the bottom of the last page of the budget and payment details
"""
self.ensure_one()
report_action = self.env.ref(report_name)
pdf_content, content_type = self.env['ir.actions.report']._render_qweb_pdf(report_action.id, [self.id])
pdf_stream = io.BytesIO(pdf_content)
pdf_reader = PdfReader(pdf_stream)
return len(pdf_reader.pages) ​​
0
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
How to hide units of measure in PDF reports?
sales debug pdf
Avatar
Avatar
Avatar
3
Oct 25
515
adding custom field in quotation/invoice
sales pdf
Avatar
Avatar
1
Nov 25
381
Customizing the Quotation PDF: How to add a customer contact person on PDF sales order? Odoo 18.3
debug pdf
Avatar
Avatar
Avatar
3
Sep 25
869
Odoo 18 Quotation Builder Header/Footer Print Problem Solved
sales pdf
Avatar
Avatar
2
Aug 25
4425
Digital products
sales pdf
Avatar
Avatar
1
Feb 25
8013
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