Skip to Content
Odoo Menu
  • Prihlásiť sa
  • Vyskúšajte zadarmo
  • Aplikácie
    Financie
    • Účtovníctvo
    • Fakturácia
    • Výdavky
    • Tabuľka (BI)
    • Dokumenty
    • Podpis
    Predaj
    • CRM
    • Predaj
    • POS Shop
    • POS Restaurant
    • Manažment odberu
    • Požičovňa
    Webstránky
    • Tvorca webstránok
    • eShop
    • Blog
    • Fórum
    • Živý chat
    • eLearning
    Supply Chain
    • Sklad
    • Výroba
    • Správa životného cyklu produktu
    • Nákup
    • Údržba
    • Manažment kvality
    Ľudské zdroje
    • Zamestnanci
    • Nábor zamestnancov
    • Voľné dni
    • Hodnotenia
    • Odporúčania
    • Vozový park
    Marketing
    • Marketing sociálnych sietí
    • Email marketing
    • SMS marketing
    • Eventy
    • Marketingová automatizácia
    • Prieskumy
    Služby
    • Projektové riadenie
    • Pracovné výkazy
    • Práca v teréne
    • Helpdesk
    • Plánovanie
    • Schôdzky
    Produktivita
    • Tímová komunikácia
    • Schvalovania
    • IoT
    • VoIP
    • Znalosti
    • WhatsApp
    Third party apps Odoo Studio Odoo Cloud Platform
  • Priemyselné odvetvia
    Retail
    • Book Store
    • Clothing Store
    • Furniture Store
    • Grocery Store
    • Hardware Store
    • Toy Store
    Food & Hospitality
    • Bar and Pub
    • Reštaurácia
    • Fast Food
    • Guest House
    • Beverage distributor
    • Hotel
    Reality
    • Real Estate Agency
    • Architecture Firm
    • Konštrukcia
    • Estate Managament
    • Gardening
    • Property Owner Association
    Poradenstvo
    • Accounting Firm
    • Odoo Partner
    • Marketing Agency
    • Law firm
    • Talent Acquisition
    • Audit & Certification
    Výroba
    • Textile
    • Metal
    • Furnitures
    • Jedlo
    • Brewery
    • Corporate Gifts
    Health & Fitness
    • Sports Club
    • Eyewear Store
    • Fitness Center
    • Wellness Practitioners
    • Pharmacy
    • Hair Salon
    Trades
    • Handyman
    • IT Hardware and Support
    • Solar Energy Systems
    • Shoe Maker
    • Cleaning Services
    • HVAC Services
    Iní
    • Nonprofit Organization
    • Environmental Agency
    • Billboard Rental
    • Photography
    • Bike Leasing
    • Software Reseller
    Browse all Industries
  • Komunita
    Vzdelávanie
    • Tutoriály
    • Dokumentácia
    • Certifikácie
    • Školenie
    • Blog
    • Podcast
    Empower Education
    • Vzdelávací program
    • Scale Up! Business Game
    • Visit Odoo
    Softvér
    • Stiahnuť
    • Porovnanie Community a Enterprise vierzie
    • Releases
    Spolupráca
    • Github
    • Fórum
    • Eventy
    • Preklady
    • Staň sa partnerom
    • Services for Partners
    • Register your Accounting Firm
    Služby
    • Nájdite partnera
    • Nájdite účtovníka
    • Meet an advisor
    • Implementation Services
    • Zákaznícke referencie
    • Podpora
    • Upgrades
    ​Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Získajte demo
  • Cenník
  • Pomoc

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

  • CRM
  • e-Commerce
  • Účtovníctvo
  • Sklady
  • PoS
  • Projektové riadenie
  • MRP
All apps
You need to be registered to interact with the community.
All Posts People Badges
Tagy (View all)
odoo accounting v14 pos v15
About this forum
You need to be registered to interact with the community.
All Posts People Badges
Tagy (View all)
odoo accounting v14 pos v15
About this forum
Pomoc

Adding Custom CSS to PDF Reports

Odoberať

Get notified when there's activity on this post

This question has been flagged
css-styleCSS
1 Odpoveď
1956 Zobrazenia
Avatar
Simon Landaverde

Hello,

I am trying to add custom CSS to a PDF Report that I have created. I just wanted to know the proper way of doing this. I have been able to successfully apply my CSS to the PDF report but when testing the installation of the module on a new build I get many errors during testing.

How I included my CSS in the Manifest:

'assets' : {

        'web.report_assets_common' : [

            'my_module/static/src/css/style.css' ,

        ],

    }

Errors I get:

FAIL: TestReportsRendering.test_layout Traceback (most recent call last): File "/home/odoo/src/odoo/odoo/addons/base/tests/test_reports.py", line 367, in test_layout self.assertEqual( AssertionError: Lists differ: [['LT[82 chars]Page:', '/ 1', '1'], ['LTFigure', 'Some header[76 chars]'1']] != [['LT[82 chars]Page: 1 / 1'], ['LTFigure', 'Some header Text'[64 chars] 1']]

FAIL: TestReportsRendering.test_pdf_render_page_overflow Traceback (most recent call last): File "/home/odoo/src/odoo/odoo/addons/base/tests/test_reports.py", line 458, in test_pdf_render_page_overflow self.assertEqual(len(pages), 6, AssertionError: 4 != 6 : 6 pages are expected, 3 per record (you may ensure `nb_lines` has a correct value to generate an oveflow)

FAIL: TestReportsRendering.test_report_pdf_page_break Traceback (most recent call last): File "/home/odoo/src/odoo/odoo/addons/base/tests/test_reports.py", line 442, in test_report_pdf_page_break self.assertEqual(pages_contents, expected_pages_contents) AssertionError: Lists differ: [['LT[82 chars]Page:', '/ 2', '1'], ['LTFigure', 'Some header[306 chars]'2']] != [['LT[82 chars]Page: 1 / 2'], ['LTFigure', 'Some header Text'[282 chars] 2']] 

FAIL: TestReportsRendering.test_thead_tbody_repeat Traceback (most recent call last): File "/home/odoo/src/odoo/odoo/addons/base/tests/test_reports.py", line 521, in test_thead_tbody_repeat self.assertEqual(len(pages), 6, '6 pages are expected, 3 per record (you may ensure `nb_lines` has a correct value to generate an oveflow)') AssertionError: 4 != 6 : 6 pages are expected, 3 per record (you may ensure `nb_lines` has a correct value to generate an oveflow) 

These errors are only present when I have my CSS loaded in my manifest. Any guidance would be much appreciated.

Thanks,
Simon

0
Avatar
Zrušiť
Avatar
Odiware Technologies
Best Answer

You're really close! The issue you're hitting is common when adding custom CSS to Odoo PDF reports via web.report_assets_common. While it works visually, it can break PDF rendering tests if the CSS introduces layout shifts, changes margins, or affects pagination.

✅ Best Practice for Custom PDF CSS in Odoo:

Instead of injecting your styles in web.report_assets_common, which affects all reports and test cases globally, you should isolate your CSS to only your specific report.

✅ Solution (Recommended Approach):

Use the report_layout asset bundle only within your report QWeb template, like this:

1. Keep CSS in your module:

plaintext

CopyEdit

my_module/static/src/css/my_report.css

2. Do NOT add it to web.report_assets_common in the manifest.

3. Instead, load it in your QWeb template like this:

xml

CopyEdit

<t t-name="my_module.my_report_template"> <t t-call="web.html_container"> <t t-call-assets="web.report_assets_common" t-js="false"/> <t t-call-assets="my_module.assets_report" t-js="false"/> <!-- Your report content --> </t> </t>

4. Define the custom asset bundle in __manifest__.py:

python

CopyEdit

'assets': { 'my_module.assets_report': [ 'my_module/static/src/css/my_report.css', ], }

✅ Why This Works:

  • Keeps the CSS scoped only to your report.
  • Prevents global test failures like test_layout and test_page_break, which are sensitive to CSS overflow or layout changes.
  • Ensures future compatibility across Odoo versions and PDF engines like wkhtmltopdf or weasyprint.

0
Avatar
Zrušiť
Enjoying the discussion? Don't just read, join in!

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

Registrácia
Related Posts Replies Zobrazenia Aktivita
CSS Flexbox Layout Issue: Seeking Guidance for Troubleshooting
CSS
Avatar
0
jan 24
1825
Getting CSS Style error while Accessing the site
css-style Error
Avatar
0
aug 24
1964
How to modify dropdown "more" arrow on smart button list in odoo 14 Solved
v14 CSS
Avatar
Avatar
1
feb 23
2649
Customized CSS and JS
css-style Js
Avatar
Avatar
1
okt 20
1559
local odoo 9 site broken. css? error Solved
odoo9 css-style
Avatar
1
aug 15
4997
Komunita
  • Tutoriály
  • Dokumentácia
  • Fórum
Open Source
  • Stiahnuť
  • Github
  • Runbot
  • Preklady
Služby
  • Odoo.sh hosting
  • Podpora
  • Vyššia verzia
  • Custom Developments
  • Vzdelávanie
  • Nájdite účtovníka
  • Nájdite partnera
  • Staň sa partnerom
O nás
  • Naša spoločnosť
  • Majetok značky
  • Kontaktujte nás
  • Pracovné ponuky
  • Eventy
  • Podcast
  • Blog
  • Zákazníci
  • Právne dokumenty • Súkromie
  • Bezpečnosť
الْعَرَبيّة 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 je sada podnikových aplikácií s otvoreným zdrojovým kódom, ktoré pokrývajú všetky potreby vašej spoločnosti: CRM, e-shop, účtovníctvo, skladové hospodárstvo, miesto predaja, projektový manažment atď.

Odoo prináša vysokú pridanú hodnotu v jednoduchom použití a súčasne plne integrovanými biznis aplikáciami.

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