Enable Dark Mode!
how-to-add-custom-paper-format-in-odoo-17.jpg
By: Cybrosys Technologies

How to Add Custom Paper Format in Odoo 17

Technical Odoo 17

In business reporting, Odoo 17 emerges as a versatile and powerful platform. With a focus on generating reports for various aspects like sales, purchases, and more, Odoo relies on QWeb reports in the widely used PDF format. Odoo's flexibility sets it apart, enabling users to define custom paper formats based on their preferences.

This blog will guide you through adding a custom paper format.

Below, you'll find an example code snippet that demonstrates the creation of a custom paper format in Odoo.

<record id="paperformat_scrap_reports" model="report.paperformat">
    <field name="name">Scrap Reports</field>
    <field name="default" eval="True"/>
    <field name="format">custom</field>
    <field name="page_height">297</field>
    <field name="page_width">500</field>
    <field name="orientation">Landscape</field>
    <field name="margin_top">30</field>
    <field name="margin_bottom">23</field>
    <field name="margin_left">5</field>
    <field name="margin_right">5</field>
    <field name="header_line" eval="False"/>
    <field name="header_spacing">20</field>
    <field name="dpi">90</field>
    <field name="disable_shrinking" eval="True"/>
</record>

First, define a new record in Odoo. It indicates that you are defining a custom paper format for reports.

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

Specifies the name of the custom paper format, which is "Scrap Reports" in this case.

<field name="name">Scrap Reports</field>

Sets this paper format as the default for reports.

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

Indicates that this is a custom paper format.

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

Specifies the height and width of the paper in millimeters.

<field name="page_height">297</field>
<field name="page_width">500</field>

Sets the paper orientation to Landscape or Portrait.

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

The screenshot below illustrates the Portrait orientation.

How to Add Custom Paper Format in Odoo 17-cybrosys

Defines the top, bottom, left, and right margins of the paper in millimeters.

<field name="margin_top">30</field>
<field name="margin_bottom">23</field>
<field name="margin_left">5</field>
<field name="margin_right">5</field>

We can enable and disable the header line in the report.

<field name="orientation">Landscape</field>
<field name="header_line" eval="True"/>

The screenshot below illustrates the header_line set to True and the orientation set to Landscape.

How to Add Custom Paper Format in Odoo 17-cybrosys

Sets the spacing for the header.

<field name="header_spacing">20</field>

Specifies the dots per inch (dpi) for the report, which indicates the level of detail or resolution in the printed output. A higher DPI value results in a more detailed and clearer print.

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

We can set disable_shrinking to True or False, indicating whether the automatic shrinking functionality is enabled or disabled. 

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

The screenshot below demonstrates the appearance when disable_shrinking is set to True.

How to Add Custom Paper Format in Odoo 17-cybrosys

The following screenshot illustrates the appearance when disable_shrinking is set to False.

How to Add Custom Paper Format in Odoo 17-cybrosys

After installing or upgrading our custom module, the custom paper format becomes available. To access it, navigate to Settings -> Technical -> Reporting -> Paper Formats, where you will find the newly added custom paper format.

How to Add Custom Paper Format in Odoo 17-cybrosys

There is an additional field known as "Associated Reports," which is a One2many field displaying reports linked to this specific paper format.

We can use the paper format in our report by referencing its ID.

<record id="scrap_move_report_pdf_action" model="ir.actions.report">
        <field name="name">Scrap Products Report</field>
        <field name="model">scrap.move.report</field>
        <field name="report_type">qweb-pdf</field>
        <field name="paperformat_id"
               ref="scrap_move_report.paperformat_inventory_reports"/>
        <field      name="report_name">scrap_move_report.scrap_pdf_report</field>
        <field name="report_file">scrap_move_report.scrap_pdf_report</field>
</record>

By using these steps, you can make your reports look better and fit your business needs in Odoo 17.


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



0
Comments



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