Search Here

Create QWEB Custom Report using Abstract Model in Odoo

Qweb Reporting Engine | To day you will learn how to create custom reports in Odoo using QWEB reporting engine. In this post we will learn how to create simple custom reports and its template using QWEB.

What is QWEB

Qweb is a reporting engine or template engine used by Odoo. By using this (QWEB) we can create reports in odoo. It uses XML to create design of reports as per your need. We can also say that QWEB is XML based reporting engine for OpenERP/Odoo.


Models.py



Description

Here we describe important lines, In line no 1 we declare a class named  "example_report" and here we use "AbstractModel", for creating our reports.


In line no 2 we declare the name of our report (Note: Here the important things is the name of the report should be same as the name of "template_id" which is created in xml file of the report.) and  In line no 14 we render our "Data" to xml files.

XML




Description

Here the name of template id (report_my_custom_report) is same as the name of report (Line no 2 in Model.py file).


The screen shot of above report is given below:

Create QWEB Custom Report using Abstract Model in Odoo

 

Post a Comment

4 Comments

  1. Replies
    1. Yes good question :) you can call that report on button click. I will share this code on Monday. Thanks

      Delete
    2. @api.multi
      def view_report_button(self):
      #your logic goes here for data
      return {
      'type': 'ir.actions.report.xml',
      'report_name': 'your_module_name.report_you_report_template_id',
      'report_type':"qweb-pdf",
      'data':{'key1':value1,'key2':value2},
      }

      Above is the code for button to open report.

      Delete
    3. does this works in odoo11? I heard "report" has been eliminated from odoo 11

      Delete