We used cookies to ensure that we give you the best experience on our website. If you continue to use this site we will assume that you are happy with it. What For?

« 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.
 
student_attendance_report.xml

 

<report

    id="action_report_student_attendance"

    model="student.attendance"

    string="Attendance Report"

    report_type="qweb-pdf"

    file="Student_attendance.report_studentattendancelist"

    name="Student_attendance.report_studentattendancelist"

/>

 

 

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>.
 
           Create Attendance Report in Odoo 8          
 
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
 
<?xml version="1.0" encoding="utf-8"?> 
<openerp>
   <data>
       <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--->
                             </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.) 
 
            Create Attendance Report in Odoo 8  
 
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')"/>

       </t>

   </t>

</template>

 

Please take a look at attached module Student_attendance for reference.

 
Download
 
 
 
contact-us Request a callback WhatsApp