Skip to Content
Odoo Menu
  • Log ind
  • Prøv gratis
  • Apps
    Økonomi
    • Bogføring
    • Fakturering
    • Udgifter
    • Regneark (BI)
    • Dokumenter
    • e-Signatur
    Salg
    • CRM
    • Salg
    • POS Butik
    • POS Restaurant
    • Abonnementer
    • Udlejning
    Hjemmeside
    • Hjemmesidebygger
    • e-Handel
    • Blog
    • Forum
    • LiveChat
    • e-Læring
    Forsyningskæde
    • Lagerbeholdning
    • Produktion
    • PLM
    • Indkøb
    • Vedligeholdelse
    • Kvalitet
    HR
    • Medarbejdere
    • Rekruttering
    • Fravær
    • Medarbejdersamtaler
    • Anbefalinger
    • Flåde
    Marketing
    • Markedsføring på sociale medier
    • E-mailmarketing
    • SMS-marketing
    • Arrangementer
    • Automatiseret marketing
    • Spørgeundersøgelser
    Tjenester
    • Projekt
    • Timesedler
    • Udkørende Service
    • Kundeservice
    • Planlægning
    • Aftaler
    Produktivitet
    • Dialog
    • Godkendelser
    • IoT
    • VoIP
    • Vidensdeling
    • WhatsApp
    Tredjepartsapps Odoo Studio Odoo Cloud-platform
  • Brancher
    Detailhandel
    • Boghandel
    • Tøjforretning
    • Møbelforretning
    • Dagligvarebutik
    • Byggemarked
    • Legetøjsforretning
    Mad og værtsskab
    • Bar og pub
    • Restaurant
    • Fastfood
    • Gæstehus
    • Drikkevareforhandler
    • Hotel
    Ejendom
    • Ejendomsmægler
    • Arkitektfirma
    • Byggeri
    • Ejendomsadministration
    • Havearbejde
    • Boligejerforening
    Rådgivning
    • Regnskabsfirma
    • Odoo-partner
    • Marketingbureau
    • Advokatfirma
    • Rekruttering
    • Audit & certificering
    Produktion
    • Tekstil
    • Metal
    • Møbler
    • Fødevareproduktion
    • Bryggeri
    • Firmagave
    Heldbred & Fitness
    • Sportsklub
    • Optiker
    • Fitnesscenter
    • Kosmetolog
    • Apotek
    • Frisør
    Håndværk
    • Handyman
    • IT-hardware og support
    • Solenergisystemer
    • Skomager
    • Rengøringsservicer
    • VVS- og ventilationsservice
    Andet
    • Nonprofitorganisation
    • Miljøagentur
    • Udlejning af billboards
    • Fotografi
    • Cykeludlejning
    • Softwareforhandler
    Gennemse alle brancher
  • Community
    Få mere at vide
    • Tutorials
    • Dokumentation
    • Certificeringer
    • Oplæring
    • Blog
    • Podcast
    Bliv klogere
    • Udannelselsesprogram
    • Scale Up!-virksomhedsspillet
    • Besøg Odoo
    Få softwaren
    • Download
    • Sammenlign versioner
    • Udgaver
    Samarbejde
    • Github
    • Forum
    • Arrangementer
    • Oversættelser
    • Bliv partner
    • Tjenester til partnere
    • Registrér dit regnskabsfirma
    Modtag tjenester
    • Find en partner
    • Find en bogholder
    • Kontakt en rådgiver
    • Implementeringstjenester
    • Kundereferencer
    • Support
    • Opgraderinger
    Github Youtube Twitter LinkedIn Instagram Facebook Spotify
    +1 (650) 691-3277
    Få en demo
  • Prissætning
  • Hjælp

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

  • CRM
  • e-Commerce
  • Bogføring
  • Lager
  • PoS
  • Projekt
  • MRP
All apps
Du skal være registreret for at interagere med fællesskabet.
All Posts People Emblemer
Tags (View all)
odoo accounting v14 pos v15
Om dette forum
Du skal være registreret for at interagere med fællesskabet.
All Posts People Emblemer
Tags (View all)
odoo accounting v14 pos v15
Om dette forum
Hjælp

Adding Custom CSS to PDF Reports

Tilmeld

Få besked, når der er aktivitet på dette indlæg

Dette spørgsmål er blevet anmeldt
css-styleCSS
1 Svar
2005 Visninger
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
Kassér
Avatar
Odiware Technologies
Bedste svar

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
Kassér
Enjoying the discussion? Don't just read, join in!

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

Tilmeld dig
Related Posts Besvarelser Visninger Aktivitet
CSS Flexbox Layout Issue: Seeking Guidance for Troubleshooting
CSS
Avatar
0
jan. 24
1854
Getting CSS Style error while Accessing the site
css-style Error
Avatar
0
aug. 24
2002
How to modify dropdown "more" arrow on smart button list in odoo 14 Løst
v14 CSS
Avatar
Avatar
1
feb. 23
2677
Customized CSS and JS
css-style Js
Avatar
Avatar
1
okt. 20
1586
local odoo 9 site broken. css? error Løst
odoo9 css-style
Avatar
1
aug. 15
5024
Community
  • Tutorials
  • Dokumentation
  • Forum
Open Source
  • Download
  • Github
  • Runbot
  • Oversættelser
Tjenester
  • Odoo.sh-hosting
  • Support
  • Opgradere
  • Individuelt tilpasset udvikling
  • Uddannelse
  • Find en bogholder
  • Find en partner
  • Bliv partner
Om os
  • Vores virksomhed
  • Brandaktiver
  • Kontakt os
  • Stillinger
  • Arrangementer
  • Podcast
  • Blog
  • Kunder
  • Juridiske dokumenter • Privatlivspolitik
  • Sikkerhedspolitik
الْعَرَبيّة 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 er en samling open source-forretningsapps, der dækker alle dine virksomhedsbehov – lige fra CRM, e-handel og bogføring til lagerstyring, POS, projektledelse og meget mere.

Det unikke ved Odoo er, at systemet både er brugervenligt og fuldt integreret.

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