How To Develop a New Report In Odoo
How To Develop A New Report In Odoo
Odoo reports collate a lot of data around your company which can provide useful information for manipulation & management of the company data. These reports are a detailed explanation of all the spending & profits in the business. But sometimes, some small details are excluded in these default reports. There is also sometimes a need for creating new reports with a completely different format. This blog covers the whole process which is needed for creating a new report with your own custom format & design it like you want.
In this scenario, we will talk about creating our very own report in Odoo Development. The more suitable method of adding your own customized report to the Odoo Module is by adding a separate button for the custom report.
Suppose we want to print a sale order/quotation report in Odoo with our own content.
We can define the paperformat, customize headers & footers & add the fields according to our needs.
For doing this, we need to add a button in both the .py & .xml file of our module.
The procedure for creating the custom module would be same involving the formation of both __init__.py & __manifest__.py file.
First of all, we’ll define the button & its function in the .py file.....
- First of all open the .py file of the custom module.
- Now inherit the class SaleOrder of the sale module.
- Now create a method for calling the button/template of the customized report.
After creating this method in our .py file, we have generated a method for calling the custom report through a button.
Now we just need to specify the location where our button will be shown in the form view. This is done using xpath in the inherited view file.
Now inherit the view file of the form view & add the button/method like this.
The xpath used in this case is header & the position is inside. This will add the custom button in the header. Now we just need to customize the report.
Steps for creating the custom report .......
- Create a .xml file inside the report folder.
- Create a template for the custom report.
- Put your content inside the report.
The external layout for header & footer can be generated separately by using template id or simply call:
instead of “web.html_container” for using the default layout for header & footer in Odoo.
The paperformat of the custom report can also be specified in this file
We can specify various things like format of the report, page size, width & height,
header spacing margin from top & bottom etc using this paperformat.
The report content can be customized according to the needs. We can add tables, rows, columns & all the content needed for designing the report using basic HTML & CSS styling.
Now the last thing that is required for completion of this report is to create an action for this report. It is necessary to create the action for this report for calling of this report inside the form view. The custom paperformat, if given needs to be called inside this report action. The name of the report generated will also be specified here inside this report action.
Completing all these steps will lead to the successful generation of a customized pdf report on clicking the button.
Hope the above information helps you. If you have any question or query related to developing reports in Odoo, feel free to ask in the comment section. Regarding any type of Odoo Services connect us via fill the Contact Us Form.