blog

How to Create Excel report Using Odoo in Simple steps | odoo excel report
News & Events Quick Tips

Creating Excel Report Using Odoo 

The reports will provide important details to help develop future forecasts marketing plans, guide budget planning, and improve decision-making. In addition to tracking progress and growth, managers also use business reports for identifying trends or any irregularities that may require further investigation.For all organizations, Excel report play a very important role.

In Excel, data manipulation and representation can be done very easily. In Odoo, you can easily custom your own excel report. As you know that by default, Odoo does not support XLS files. So by using the ‘report_xls’ module, you can download it.

Here, we can create an excel report from a wizard.

Wizard Creation

A wizard is a transient model in Odoo. The fields in the wizards are used to filter the content in the report.

Python file 

 from odoo import API, fields, models

class WizardClassName(models.TransientModel):

            _name = 'wizard.wizard'

            _description = 'XLS Report'

           date = field.Date(string=”Date”)

XML File

Also, create a .xml file for the wizard to display on the user interface

<record id="view_wizard_report" model="ir.ui.view">    

<field name="name">Wizard sample</field>    

<field name="model">wizard.wizard</field>    

<field name="arch" type="xml">        

<form string="Choose your details">    

<group>       

<group> 

<field name="start_date" />          

 </group>

</group>           

<footer>                

<button name="export_xls_report" string="Export" type="object" 

class="oe_highlight" 

/>                

or                

<button string="Cancel" class="oe_link" special="cancel"/>           

</footer>        

</form>    

</field>
</record>

You can specify the action and menu item of the wizard in this XML file.

You can write a method in the python file to fetch the data and render the excel report id.

Creating an action for a report is referred to as a report action. The report action will be recognized by the model ‘ir.actions.report’ used in the record. Create a report action in your view file as shown below.

 <record id="action_report_wizard_id" model="ir.actions.report">

   <field name="name"><Wizard Sample<field>

   <field name="model">wizard.wizard</field>

   <field name="report_type">xlsx</field>

   <field name="report_name">report_wizard_id</field&gt;

   <field name="report_file">module_name.report_wizard_id</field>

   <field name="print_report_name">Wizard Sample</field>

</record> 

Here you can specify the name of the report, the model where you want to fetch data for your excel report and the report type and the id of the main report function.

You can specify the main method in the python file. An example is given below.

 from odoo import models

 class ReportExcel(models.AbstractModel):

                   _name = "report.module_name.report_wizard_id"

                   _inherit = "report.report_xlsx.abstract"

         def generate_xlsx_report(self, workbook, data, lines):

                   ws = workbook.add_worksheet("Report")

                             // Add a name for your workbook

                   ws.set_column(“A:A”,10)

ws.set_column(“B:B”,10)

         //Set the column size

sample_heading_format = (

{

   “bold”:True,

   “font_size”:20,

   “align”:center,

  “border”:True,

}

                            )

sample_format = (

{

   “bold”:True,

   “font_size”:16,

   “align”:center,

  “border”:True,

}

                            )         

// You can set the formats here and use them in your worksheet.

ws.merge_range(“A1:A13”,”Sample Excel Report”,sample_heading_format)

                   // By using merge_range function you can merge your columns/rows.

ws.write(“B1:B13”,”This is Sample Excel Report”,sample_format)

                   // Write function is used to write the values to your excel.

You can easily customize your excel report according to your need in odoo. The module ‘report_xlsx’ version also changes depending on your odoo version.

If you plan a new ERP Software implementation and you have heard about Odoo and got attracted by the Odoo ERP platform, decided to use it but don’t have time, resources, or knowledge to manage this yourself, thereby looking for professional assistance, then you have come to a right place. Bassam Infotech has implemented scores of Odoo ERP all around the world. In addition, we have also developed and delivered our own customized Odoo applications with minimal Odoo implementation cost.

DOWNLOAD Odoo Excel Report Creation

Bassam Infotech is a company of Official Odoo Certified Experts with 24 years of expertise. We are a one-stop shop for all your business needs, including Odoo Implementation, customization, integration, and support. We’re available by phone or email, with a 24-hour response time in case you need immediate Odoo ERP support. For more details, Call us on +91 88912 49995 or +91 70250 75566 email us at info@bassaminfotech.com or fill out the form to get a free consultation

Leave a Reply

Your email address will not be published. Required fields are marked *

Open chat
1
Hello, can we help you?