Report Creation in Odoo 8.0 - ST 2024
Report Creation in Odoo 8.0
In Odoo report is generated through Report module. Here are the steps to generate simple QWEB report.
Step 1 : Define the Report through <report> tag with following configuration.
Report tag is in the file whose name should be <module_name>_report.xml which we have to add in ‘data’ list of __openerp__.py.
student_attendance_report.xml
In this,
Id : Unique identifier of report which is declared in ir.model.data.
String (mandatory) : It is name of the report which is displayed in view of the list of print button.
Model (mandatory) : Model for which we want to create report.
Report_type (mandatory) : either qweb-pdf for PDF reports or qweb-html for HTML
"HTML format" means that the content is displayed as a web page, which is good for browsing an article on screen.
A PDF (portable document format) is better for printing because it will preserve the layout that was presented in the print journal, including illustrations. You can also save a PDF to your computer's hard drive.
Report_name(mandatory) : The name of our report (which will be the name of the PDF generated)
File : It is our qweb-template view file. The name of this file should be <module_name>.report_<type_of_report>.
Step 2 : Define the report template.
For that we have to add template file with the name which is declared in ‘file’ attribute of <report> tag.Here is the name that should be in views/report_studentattendancelist. (No need to add module name here.). We have to add this file in ‘data’ list of __openerp__.py file.
views/report_studentattendancelist.xml
<!-- Add view format of report here---> </div> </t> </t> </template> </data> </openerp>
In this,
Body of our report is declared inside the <div class=”page”>.
Id : Id must be the name specified in report declaration. For example:- report_studentattendancelist
Docs : Records for the current report. It provides the data of our current model.
After both these steps we can print report through the view of this model. Just select any record click on
Print -> Report String (For example : Attendance Report which is defined in report declaration.)
We can also change in the report template from UI by the following link.
Settings -> Technical -> Reports -> Reports -> Select report -> click on Search associated QWEB views -> select your report view -> Edit the report in the Architecture.
We can also add translation(Language) easily through following template in report template file.
Please take a look at attached module Student_attendance for reference.
Download
For Your Business Requirements
2 - 4 October 2024
Hall: 10, Booth: #B8 Brussels, Belgium