« Back to Blogs

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.





    string="Attendance Report"







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.
<?xml version="1.0" encoding="utf-8"?> 
       <template id="report_studentattendancelist">
             <t t-call="report.html_container">
                 <t t-foreach="docs" t-as="o">
                      <t t-call="report.internal_layout">
                            <div class="page">
                                   <div class="oe_structure"/>
                                     <!-- Add view format of report here--->
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.


<template id="report_stuent_attendance">

   <t t-call="report.html_container">

       <t t-foreach="docs" t-as="doc_id">

<t t-raw="translate_doc(doc_id, doc_model, 'partner_id.lang','Student_attendance.report_studentattendancelist')"/>





Please take a look at attached module Student_attendance for reference.

manoel isaac Balam Herrera
Hello am following your great work, and trying to reply the exercise, but i get this error.

Wkhtmltopdf failed (error code: -6). Message: The switch --header-spacing, is not support using unpatched qt, and will be ignored.

can you help me?, thanks in advance
Posted on 11/16/15 11:31 AM.
Surekha Tech
You need to install wkhtmltopdf on your system to print pdf report. Following are steps to install this package in linux based system :

Download the wkhtmltox- from http://wkhtmltopdf.org/downloads.html

To install Wkhtmltopdf
1) sudo apt-get install xfonts-75dpi
2) sudo dpkg -i wkhtmltox-
3) Restart the odoo server

If your operating system is different then you can download proper package from http://wkhtmltopdf.org/downloads.html link.
Posted on 11/16/15 3:54 PM in reply to manoel isaac Balam Herrera.
manoel isaac Balam Herrera
sorry for my discourtesy, many thanks in advance
Posted on 10/15/16 7:57 PM in reply to Chandrika Baraiya.
contact-us Request a callback WhatsApp