Bỏ qua để đến Nội dung
Odoo Menu
  • Đăng nhập
  • Dùng thử miễn phí
  • Ứng dụng
    Tài chính
    • Kế toán
    • Hóa đơn
    • Chi phí
    • Bảng tính (BI)
    • Tài liệu
    • Ký tên
    Bán hàng
    • CRM
    • Bán hàng
    • POS Cửa hàng
    • POS Nhà hàng
    • Đăng ký
    • Cho thuê
    Trang web
    • Trình tạo trang web
    • Thương mại điện tử
    • Blog
    • Diễn đàn
    • Trò chuyện trực tiếp
    • Học trực tuyến
    Chuỗi cung ứng
    • Tồn kho
    • Sản xuất
    • PLM
    • Mua hàng
    • Bảo dưỡng
    • Chất lượng
    Nhân sự
    • Nhân viên
    • Tuyển dụng
    • Ngày nghỉ
    • Đánh giá
    • Giới thiệu
    • Đội xe
    Marketing
    • Marketing trên MXH
    • Marketing qua email
    • Marketing qua SMS
    • Sự kiện
    • Tự động hóa Marketing
    • Khảo sát
    Dịch vụ
    • Dự án
    • Bảng chấm công
    • Dịch vụ hiện trường
    • Hỗ trợ
    • Kế hoạch
    • Lịch hẹn
    Năng suất
    • Thảo luận
    • Phê duyệt
    • IoT
    • VoIP
    • Kiến thức
    • WhatsApp
    Ứng dụng của bên thứ ba Studio Odoo Nền tảng Đám mây Odoo
  • Ngành
    Bán lẻ
    • Nhà sách
    • Cửa hàng quần áo
    • Cửa hàng nội thất
    • Cửa hàng tạp hóa
    • Cửa hàng đồ kim khí
    • Cửa hàng đồ chơi
    Ẩm thực & Dịch vụ lưu trú
    • Bar và quán rượu
    • Nhà hàng
    • Đồ ăn nhanh
    • Guest house
    • Nhà phân phối đồ uống
    • Khách sạn
    Bất động sản
    • Công ty môi giới bất động sản
    • Công ty kiến trúc
    • Xây dựng
    • Quản lý bất động sản
    • Làm vườn
    • Hiệp hội chủ sở hữu bất động sản
    Tư vấn
    • Công ty kế toán
    • Đối tác Odoo
    • Công ty marketing
    • Công ty luật
    • Tuyển dụng
    • Thanh tra & chứng nhận
    Sản xuất
    • Dệt may
    • Kim loại
    • Nội thất
    • Ẩm thực
    • Nhà máy bia
    • Quà tặng doanh nghiệp
    Sức khoẻ & fitness
    • CLB thể thao
    • Cửa hàng kính mắt
    • Trung tâm fitness
    • Chuyên gia chăm sóc sức khỏe
    • Hiệu thuốc
    • Tiệm làm tóc
    Thương mại
    • Dịch vụ sửa chữa
    • Phần cứng CNTT & Hỗ trợ
    • Hệ thống năng lượng mặt trời
    • Công ty sản xuất giày
    • Dịch vụ vệ sinh
    • Dịch vụ HVAC
    Khác
    • Tổ chức phi lợi nhuận
    • Cơ quan môi trường
    • Cho thuê biển quảng cáo
    • Nhiếp ảnh
    • Cho thuê xe đạp
    • Đại lý phần mềm
    Xem tất cả ngành
  • Cộng đồng
    Học tập
    • Khóa học
    • Tài liệu
    • Chứng chỉ
    • Đào tạo
    • Blog
    • Podcast
    Thúc đẩy đào tạo
    • Chương trình đào tạo
    • Trò chơi kinh doanh Scale Up!
    • Tham quan Odoo
    Nhận phần mềm
    • Tải xuống
    • So sánh các phiên bản
    • Phiên bản
    Hợp tác
    • Github
    • Diễn đàn
    • Sự kiện
    • Dịch thuật
    • Trở thành đối tác
    • Dịch vụ dành cho Đối tác
    • Đăng ký công ty kế toán của bạn
    Nhận dịch vụ
    • Tìm đối tác
    • Tìm kế toán
    • Gặp chuyên gia hỗ trợ
    • Dịch vụ Triển khai
    • Khách hàng tham khảo
    • Hỗ trợ
    • Nâng cấp
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Nhận một buổi demo
  • Bảng giá
  • Trợ giúp

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

  • CRM
  • e-Commerce
  • Kế toán
  • Tồn kho
  • PoS
  • Dự án
  • MRP
All apps
Bạn cần phải đăng ký để tương tác với cộng đồng.
Tất cả bài viết Người Huy hiệu
Thẻ (Xem tất cả)
odoo accounting v14 pos v15
Về diễn đàn này
Bạn cần phải đăng ký để tương tác với cộng đồng.
Tất cả bài viết Người Huy hiệu
Thẻ (Xem tất cả)
odoo accounting v14 pos v15
Về diễn đàn này
Hỗ trợ

[Odoo 17] Extra Space at Top and Bottom in Custom Report after Removing Default Header/Footer

Đăng ký nhận tin

Nhận thông báo khi có hoạt động trên bài viết này

Câu hỏi này đã bị gắn cờ
2 Trả lời
1257 Lượt xem
Ảnh đại diện
MOHAMED

Hi everyone,

I'm working on a custom report in Odoo 17, and I've run into an issue with the layout.

I created a new report_paperformat and a custom report template. I removed the default Odoo header (web.external_layout) and footer, but I still have extra white space at the top and bottom of the generated PDF.

Here’s what I’ve already tried:

  • Replaced <t t-call="web.external_layout"> with my own layout using t-foreach="docs".
  • Removed any t-call="web.internal_layout" as well.
  • Defined a new paper format in report_paperformat.xml with margins set to 0.

Despite this, the PDF still includes a blank area at the top and bottom — it seems like the old margins are still applied.

🔧 My paperformat XML:

xml

CopyEdit

<record id="custom_report_paperformat" model="report.paperformat"> <field name="name">Custom Format</field> <field name="default" eval="True"/> <field name="format">A4</field> <field name="margin_top">0</field> <field name="margin_bottom">0</field> <field name="margin_left">0</field> <field name="margin_right">0</field> <field name="header_line" eval="False"/> <field name="orientation">Portrait</field> <field name="page_height">0</field> <field name="page_width">0</field> <field name="dpi">90</field> </record>

❓Question:

How can I completely remove the top and bottom spacing in the report PDF?

Is there a way to force zero margin rendering, or do I need to override something in the QWeb rendering engine or CSS?

Thank you in advance!

0
Ảnh đại diện
Huỷ bỏ
Ảnh đại diện
Cybrosys Techno Solutions Pvt.Ltd
Câu trả lời hay nhất

Hi,


This is a common issue when working with custom PDF reports in Odoo. Even after setting margins to 0 and removing the header/footer, white space may still appear. Here's how to solve it completely:


Corrected Paper Format XML:

The issue is likely caused by setting page_height and page_width to 0, which tells wkhtmltopdf to fall back to default A4 size with default margins.

You should explicitly define A4 dimensions in mm:


<record id="custom_report_paperformat" model="report.paperformat">

    <field name="name">Custom Format</field>

    <field name="default" eval="True"/>

    <field name="format">A4</field>

    <field name="margin_top">0</field>

    <field name="margin_bottom">0</field>

    <field name="margin_left">0</field>

    <field name="margin_right">0</field>

    <field name="header_line" eval="False"/>

    <field name="orientation">Portrait</field>

    <field name="page_height">297</field> <!-- A4 height in mm -->

    <field name="page_width">210</field>  <!-- A4 width in mm -->

    <field name="dpi">90</field>

</record>


Attach the Paper Format to the Report

Ensure your custom report uses this paper format:


<record id="your_custom_report_action" model="ir.actions.report">

    <field name="paperformat_id" ref="your_module.custom_report_paperformat"/>

</record>


Hope it helps.


1
Ảnh đại diện
Huỷ bỏ
Ảnh đại diện
John
Câu trả lời hay nhất

Defining a custom report and paper format and removing the default web.external_layout is the correct way to remove default Odoo headers/footers and control layout. However, extra white space still appears in the PDF, which is a common issue due to how wkhtmltopdf handles margins, especially when there are conflicts between HTML/CSS and paper format.


✅ 1. Check Report Paper Format Linkage

Make sure your report is correctly linked to the custom paperformat. In your report.xml or report_action record, add:


<record id="action_report_my_custom" model="ir.actions.report">

    <field name="name">My Custom Report</field>

    <field name="report_name">my_module.report_template_id</field>

    <field name="report_type">qweb-pdf</field>

    <field name="paperformat_id" ref="my_module.custom_report_paperformat"/>

</record>

✅ 2. Set All Margins and Page Sizes Correctly

Your paper format XML looks mostly good. Here's a safer version:

<record id="custom_report_paperformat" model="report.paperformat">

    <field name="name">Custom Format</field>

    <field name="format">A4</field>

    <field name="page_width">0</field>

    <field name="page_height">0</field>

    <field name="margin_top">0</field>

    <field name="margin_bottom">0</field>

    <field name="margin_left">0</field>

    <field name="margin_right">0</field>

    <field name="orientation">Portrait</field>

    <field name="header_line" eval="False"/>

    <field name="dpi">90</field>

    <field name="default" eval="False"/>

</record>

👉 Setting both page_height and page_width to 0 tells Odoo to use the standard A4 dimensions as per the format field.

✅ 3. Force CSS Margin Reset in Template

Sometimes, QWeb adds padding/margins via the stylesheet (report.min.css). Add a style override to your template:



<t t-name="my_module.report_template_id">

    <t t-call="web.html_container">

        <t t-set="css">

            <![CDATA[

                @page {

                    margin: 0mm !important;

                }

                body {

                    margin: 0mm !important;

                    padding: 0mm !important;

                }

                .page {

                    margin: 0mm !important;

                    padding: 0mm !important;

                }

            ]]>

        </t>

        <div class="page">

            <!-- your content -->

        </div>

    </t>

</t>

✅ This helps override any default layout styling inside .page, body, or @page.

0
Ảnh đại diện
Huỷ bỏ
Bạn có hứng thú với cuộc thảo luận không? Đừng chỉ đọc, hãy tham gia nhé!

Tạo tài khoản ngay hôm nay để tận hưởng các tính năng độc đáo và tham gia cộng đồng tuyệt vời của chúng tôi!

Đăng ký
Cộng đồng
  • Khóa học
  • Tài liệu
  • Diễn đàn
Open source
  • Tải xuống
  • Github
  • Runbot
  • Dịch thuật
Dịch vụ
  • Lưu trữ Odoo.sh
  • Hỗ trợ
  • Nâng cấp
  • Phát triển tùy chỉnh
  • Đào tạo
  • Tìm kế toán
  • Tìm đối tác
  • Trở thành đối tác
Giới thiệu công ty
  • Công ty của chúng tôi
  • Tài sản thương hiệu
  • Liên hệ
  • Việc làm
  • Sự kiện
  • Podcast
  • Blog
  • Khách hàng
  • Pháp lý • Riêng tư
  • Bảo mật
الْعَرَبيّة 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 là bộ ứng dụng kinh doanh có open source đáp ứng tất cả các nhu cầu của công ty bạn: CRM, thương mại điện tử, kế toán, tồn kho, POS, quản lý dự án, v.v.

Định hướng giá trị riêng biệt của Odoo là tích hợp hoàn toàn và dễ dàng sử dụng.

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