Enable Dark Mode!
By: Nimisha Muralidhar

How to Create New Report Layouts In Odoo 14

Technical Odoo 14

Reports help to analyze the business growth making reports an important feature in ERP software. Odoo provides different reports like PDF, pivot, and graphical representation. 
Custom reports are always needed in the business to make the business more user-friendly and easy. So to know more about the pdf report in Odoo please check the blog: How to Create a PDF Report in Odoo 14
When it comes to a custom module, we can also customize reports. As regular views in Odoo, Reports are written using HTML/QWeb. Report action and report template are used to generate reports for the action to use.
Report layout is an important factor in report generation. There are default layouts in Odoo eg:
web.external_layout. web.internal_layout etc 
We can use existing template layouts as well as create a new report layout in the custom report. In this blog, I am going to discuss,  How to create new Report Layouts.
To create an external custom layout, we need to create a template. An example template for custom layout is given below. It is an XML file that can be defined either in the report directory or in the views.
<template id="custom_external_layout">
   <t t-if="not o" t-set="o" t-value="docs"/>
   <t t-set="company" t-value="company_id"/>
   <div class="header">
       <img t-if="o.company_id.logo" t-att-src="image_data_uri(o.company_id.logo)" alt="Logo"
       <div style="font-size:12px;text-align:left;" class="float-right">
               <strong t-field="o.company_id.partner_id.name"/>
               <span t-field="o.company_id.partner_id"
                     t-options="{&quot;widget&quot;: &quot;contact&quot;, &quot;fields&quot;: [&quot;address&quot;], &quot;no_marker&quot;: true}"/>
               <span t-field="o.company_id.partner_id.website"/>
   <div class="article o_report_layout_standard" t-att-data-oe-model="o and o._name"
        t-att-data-oe-id="o and o.id" t-att-data-oe-lang="o and o.env.context.get('lang')">
       <t t-call="web.address_layout"/>
       <t t-raw="0"/>
In the above template, you can set a custom layout as per the requirement. In the example template, I have added the company logo, company name, website, and language. You can also add other details as required. Also, the design of the template can be defined in the CSS class. Which can be further used in the custom template. Also in the template, I used the web address layout which is an existing template. 
In the report template, one can retrieve docs that contain objects. So every necessary information can be retrieved from the docs. Also if needed additional information can be passed from the python to the template.
One can also customize the template by using existing templates. Ie we can call the template using t-call and all the designs in the template can be retrieved in the custom template as well.
Once you create the template, the next step is to call the template in the required report.
An example is shown below,
<template id="report_custom">
     <t t-call="web.html_container">
       <t t-call="custom_module.custom_external_layout">
Here I have a custom template with the name custom_external_layout. Which is called in the template report_custom. As you can see there is also another template html_cointainer from the web module which is also called in the template report_custom. So you can create multiple custom templates and call in the report as per needed. 
The figure below shows the custom template created,
Customize the template and create reports according to your requirements.
Happy coding!

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


Leave a comment




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



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



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

Send Us A Message