Recent Bloggers

Saurang Suthar
Posts: 5
Stars: 0
Date: 7/4/17
Jyoti Verma
Posts: 3
Stars: 0
Date: 6/28/17
Pankti Patel
Posts: 1
Stars: 0
Date: 5/26/17
Chandrika Baraiya
Posts: 5
Stars: 0
Date: 5/26/17
Atith Patel
Posts: 5
Stars: 0
Date: 5/22/17
Nisarg Pujara
Posts: 6
Stars: 0
Date: 5/10/17
Pranavsinh Parmar
Posts: 4
Stars: 0
Date: 5/3/17
Ankit Prajapati
Posts: 5
Stars: 0
Date: 5/3/17
Pratik Solanki
Posts: 5
Stars: 0
Date: 4/7/17
Chirag Patel
Posts: 4
Stars: 0
Date: 3/30/17
« Back

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>.
 
                     
 
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.) 
 
              
 
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
 
 
 
Comments
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/15/15 7:01 PM.
Chandrika Baraiya
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-0.12.2.1_linux-precise-amd64.deb from http://wkhtmltopdf.org/downloads.html

To install Wkhtmltopdf
1) sudo apt-get install xfonts-75dpi
2) sudo dpkg -i wkhtmltox-0.12.2.1_linux-precise-amd64.deb
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/15/15 11:24 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 3:27 AM in reply to Chandrika Baraiya.

Contact Us

Loading

Get in touch

Headquarter :
302, Landmark,
Nr. Titanium City Center,
Prahlad Nagar Road,
Ahmedabad, India - 380015.