India

ZestyBeanz Technologies Pvt Ltd 4th Floor, Nila, Technopark Thiruvananthapuram,
India – 695581
Phone: +91 471 4063254
Fax : +91 471 2700171

   .

ZestyBeanz Technologies Pvt Ltd
61/3236, Manikkath Cross Road
Ravipuram, Kochi, India - 682016
Phone: +91 484 4063254

  UAE

Zesty Labs
Office # 2003, Millennium Plaza Building
Sheikh Zayed Rd, Dubai, UAE
Phone: +971 4333 2222​
Mobile: +971-52-7553466

  Germany​

ZestyBeanz Technologies GmbH
Reuterstraße 1
90408 Nürnberg
Fon: +49 911 4801 444
Fax: +49 911 4801 445

Contact Form


Parvathy R's picture

Spreadsheet/Xls report in odoo using report_xls

Spreadsheet displays multiple cells usually in a two-dimensional matrix or grid consisting of rows and columns. We have so many reporting softwares that will simply create spreadsheets. But the problem is, these reporting softwares may not support on all systems and also take lot of CPU time.

XLS reports are often necessary for many business organizations. Data representation and manipulation can be done in XLS file very easily. By default, Odoo doesn’t  support  XLS file creation of a report. This blog will help you to generate XLS report with wizard using an extra module report_xls and you can download it from here: XLSX Report

Here is the simple code introduction for create the spreadsheet

  1. We can define the title, header, number, date, and normal style using add_format(). For example,
                     heading_format = workbook.add_format({'align': 'left','bold': True, 'size': 14})
  2. We can add sheet to the workbook using add_worksheet() method.
            For example, work_sheet = workbook.add_worksheet(‘Payroll Sheet’)
  3. For write into the sheet,
                    For example, work_sheet.write(4,4,’Date From’,font_size)
  4. To set width of the cell,
                    For example, work_sheet.set_column('A:A', 10)
  5. To add formula,
                    For example, worksheet.write_formula(20,4, '{=SUM(C7:C19)},normal_num_bold)

Now move on to the code

Here we are going to create an XLS report from a wizard. Wizard can be used to enter the data and based on this data we can filter the report. In this wizard, we will add some fields to filter the content of the report. So let us first look how the wizard is created.

Wizard Creation

Python file:

This is the python file created for the wizard. Here the fields start_date, end_date are filtration fields.

XML File:

This is the code for view of the wizard . In this view, the user can enter values for start date and end date. After entering the values, the user can click the ‘Print Report’ button to print the ‘Xls’ report.

Simple xls Report

For making a simple xls report in Odoo, we can go through the following steps

 - Declaring a report action

 - Defining a report

Declare a report action

In an XML file we can declare a report inside the ‘ <report></report>’  tag.

- Id:- Represents the report’s external id
- string:- Represents the Report
- model:- It is a mandatory field  which represents the model that the report will stand for
- report_type:- Type of report.  
- Name:- It is a mandatory field. It is useful for description of the report when looking for one in a list of some sort.
- File:- File Name

Defining a report

We can define a simple  report as follow.

In the above code, we have to write the last line properly. It should be like this

Classname('report.module_name.report_name.xlsx', 'model_name')

Final output of report is given below

Reply

The content of this field is kept private and will not be shown publicly.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
  • You can enable syntax highlighting of source code with the following tags: <code>, <blockcode>, <c>, <cpp>, <drupal5>, <drupal6>, <java>, <javascript>, <php>, <python>, <ruby>. The supported tag styles are: <foo>, [foo], [[foo]]. PHP source code can also be enclosed in <?php ... ?> or <% ... %>.

More information about formatting options

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
Image CAPTCHA
Enter the characters shown in the image. Ignore spaces and be careful about upper and lower case.