Update: this tutorial also works in Odoo 13
Create a custom report on Odoo 12 is little different from Odoo 11. There are several things need to modified from custom report Odoo 11. As previously custom report Odoo 11, I still use
hr_attendance report for this example and will display employee attendance summary (recap) with presence and absence data of each employee.
The final result of the report is as shown below.
For initial preparation, you must create a new database and tick “Load demonstration data”, so that there is preliminary data that we can use to test the code. Then install
hr_attendance module, this module is a default module from Odoo. And don’t forget to make sure that the
wkhtmltopdf 0.12.1 or
wkthmltopdf 0.12.5 has been installed.
After installing the
hr_attendance module, you can see attendance data with the following demo data is as shown below.
Create a wizard model.
Create a wizard model that inherits from
Create an xml wizard view.
Create a view to display the wizard based on the wizard model above.
After creating the wizard, the result is as shown below.
Modify wizard model and create a new abstract model.
get_report() in model
attendance.recap.report.wizard, and create a model that inherits from
AbstractModel. As you can see below.
Create an xml template report.
Last step is to create an xml for template report as needed.
That’s it. Please check https://github.com/CakJuice/odoo12-custom-report for full code, or you can download then install the module to try.
If you need another reference about Odoo report, you can check at https://www.odoo.com/documentation/12.0/reference/reports.html.