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 https://karisindo.id/en/blog/odoo-1/create-custom-report-in-odoo-11-3, We 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.
Initial Preparation
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 TransientModel.
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
Modify method 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.