Enable Dark Mode!
how-to-create-better-reports-using-wkhtmltopdf-in-odoo-16.jpg
By: Akhil Ashok

How to Create Better Reports Using wkhtmltopdf in Odoo 16

Technical Odoo 16 Odoo Enterprises Odoo Community

Odoo, a renowned enterprise resource planning (ERP) system, offers robust reporting capabilities. To elevate the quality of reports, Odoo seamlessly integrates with wkhtmltopdf, a command-line tool for converting HTML to PDF. In this blog post, we will explore how you can leverage wkhtmltopdf in Odoo to create visually appealing and professional reports that effectively present data.

Section 1: Understanding wkhtmltopdf 

wkhtmltopdf is a  tool used to convert HTML content into PDF format. It provides a reliable and efficient solution for generating high-quality reports in Odoo. By harnessing the capabilities of wkhtmltopdf, you can customize report layouts, add branding elements, and improve the overall aesthetics of your reports. Its seamless integration with Odoo ensures a smooth and hassle-free report generation process.

Section 2: Installing wkhtmltopdf 

To begin using wkhtmltopdf in Odoo, you need to install it on your server. You can visit the official wkhtmltopdf website or utilize package managers to download and install the appropriate version. Verifying the installation is essential to ensure that wkhtmltopdf is functioning correctly.

Section 3: Configuring Odoo to Use wkhtmltopdf 

After installing wkhtmltopdf, you must configure Odoo to utilize it for report generation. This involves modifying the Odoo configuration file to include the base URL of your Odoo instance. By correctly configuring Odoo, you enable seamless communication between Odoo's reporting framework and wkhtmltopdf.

Section 4: Creating Custom Reports 

One of the significant advantages of using wkhtmltopdf in Odoo is the ability to create custom reports. Utilizing QWeb templates, you can design and customize reports to suit your specific requirements. Whether you want to enhance an existing report or create a new one, QWeb templates offer flexibility and control. You can tailor the report structure, add dynamic content, and incorporate branding elements to create a unique and professional look.

Section 5: Generating Reports with wkhtmltopdf 

With Odoo and wkhtmltopdf properly configured, generating reports becomes a seamless process. Simply navigate to the desired record or dataset, select the appropriate report, and Odoo will utilize wkhtmltopdf to convert the report into a PDF format. The resulting PDF can be downloaded and shared with stakeholders, ensuring a visually appealing and professional presentation of data.

Section 6: Getting the Flexbox Working

One of the most common issues developers face while working with wkhtmltopdf is its somewhat unreliable support for some of the modern CSS properties. This is mainly due to the technology used behind the scenes by the wkhtmltopdf team. wkhtmltopdf uses the original QtWebKit, which is outdated and does not support many modern CSS functionalities, such as flexbox, grid, etc.

However, it’s possible to overcome this issue by adding vendor prefixes along with our usual flex ruleset. Let’s look at the example below:

display: flex; 
justify-content: center;

Sprinkling in these two lines of CSS won’t yield the desired result. But luckily, we can get this working by throwing vendor-prefix flavored properties of the same into the mix.

display: -webkit-box;
 -webkit-box-pack: center;

Adding these two along with the above lines of code will work the magic. The same rule can be observed for other properties as well.

Conclusion 

Leveraging the power of wkhtmltopdf in Odoo allows you to create better reports that effectively convey information to stakeholders. By installing, configuring, and utilizing wkhtmltopdf in conjunction with Odoo's reporting framework, you can enhance report aesthetics, customization options, and overall quality. Empower your business processes with visually appealing reports that facilitate decision-making and provide valuable insights. With wkhtmltopdf and Odoo, you can take your reporting capabilities to the next level.



If you need any assistance in odoo, we are online, please chat with us.



1
Comments

Henk de Leeuw

Any thoughts on this? In my daily FreeBSD security updates, I received the following: wkhtmltopdf-0.12.6_1: Tag: expiration_date Value: 2024-06-30 wkhtmltopdf-0.12.6_1: Tag: deprecated Value: Upstream abandoned the project Some googling produced https://github.com/odoo/odoo/issues/86501 en https://wkhtmltopdf.org/status.html Will there still be a reliable wkhtmltopdf one years from now?

12/10/2023

-

12:16PM



Leave a comment



whatsapp
location

Calicut

Cybrosys Technologies Pvt. Ltd.
Neospace, Kinfra Techno Park
Kakkancherry, Calicut
Kerala, India - 673635

location

Kochi

Cybrosys Technologies Pvt. Ltd.
1st Floor, Thapasya Building,
Infopark, Kakkanad,
Kochi, India - 682030.

location

Bangalore

Cybrosys Techno Solutions
The Estate, 8th Floor,
Dickenson Road,
Bangalore, India - 560042

Send Us A Message