Skip to Content

How to Use Custom Paper Format in Odoo Qweb Reports

July 25, 2021 by
How to Use Custom Paper Format in Odoo Qweb Reports
iWesabe

        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

in Odoo
How to Use Custom Paper Format in Odoo Qweb Reports
iWesabe July 25, 2021
Share this post

Great stories have a personality. Consider telling a great story that provides personality. Writing a story with personality for potential clients will assist with making a relationship connection. This shows up in small quirks like word choices or phrases. Write from your point of view, not from someone else's experience.

Great stories are for everyone even when only written for just one person. If you try to write with a wide, general audience in mind, your story will sound fake and lack emotion. No one will be interested. Write for one person. If it’s genuine for the one, it’s genuine for the rest.

Tags

Enhance Your Experience

Write one or two paragraphs describing your product or services. To be successful your content needs to be useful to your readers.

Start with the customer – find out what they want and give it to them.

Learn more

Archive

Enhance Your Experience

Write one or two paragraphs describing your product or services. To be successful your content needs to be useful to your readers.

Start with the customer – find out what they want and give it to them.

Learn more

Enhance Your Experience

Write one or two paragraphs describing your product or services. To be successful your content needs to be useful to your readers.

Start with the customer – find out what they want and give it to them.

Learn more