In Odoo, we can define a paper format for our report according to our convenience. In this blog we are discussing how to add a custom paper format for a qweb report in Odoo. Below is an example code used for creating a custom paper format.

<record id="custom_paperformat_id" model="report.paperformat">
    <field name="name">Custom Paper Format</field>
    <field name="default" eval="True"/>
    <field name="format">custom</field>
    <field name="page_height">297</field>
    <field name="page_width">210</field>
    <field name="orientation">Landscape</field>
    <field name="margin_top">15</field>
    <field name="margin_bottom">10</field>
    <field name="margin_left">10</field>
    <field name="margin_right">10</field>
    <field name="header_line" eval="False"/>
    <field name="header_spacing">3</field>
    <field name="dpi">90</field>
</record>

Here we will mention the name of paper format 

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


Here we will provide a predefined format (A0 to A9, B0 to B10, Legal, Letter, Tabloid etc.) or use a custom one such as A4 by default.

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

Here we will provide the page height and width in Millimeters.

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

For orientation field we can use Portrait or Landscape.

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

Here in the margin fields we can define our margin dimensions in Millimeters.

<field name="margin_top">15</field>
<field name="margin_bottom">10</field>
<field name="margin_left">10</field>
<field name="margin_right">10</field>

Here we can use a boolean expression to display a header line in your page.

<field name="header_line" eval="False"/>
By using header space we can increase or decrease space between header and page.

<field name="header_spacing">3</field>
The default dpi used in Odoo is 90, we can change it as per our needs.

<field name="dpi">90</field>
After creating the paper format we can see it in the Paper Format menu under the Reporting menu of Technical Settings.



Now we can use this paperformat for our reports using the below code.

<report id="your_custom_report_id" 
         string="Name of the report" 
         model="your model" 
         report_type="qweb-pdf" 
         file="your_module_name.your_custom_report_template" 
         name="your_module_name.your_custom_report_template" 
         paperformat="your_module_name.your_custom_paperformat_id"/>


These are the steps to add a custom paper format to a custom qweb report in Odoo.

If you wish to have the latest updates from us, you may follow us on