View source | Discuss this page | Page history | Printable version   

How to create a Report



The goal of this how to is to describe the steps required to create a new report in Openbravo 3. The example explained is a simple report with a list of products.


Before starting make sure that you have read the prerequisite knowledge article. And you are confident with Openbravo modularity concepts

Setting up Jaspersoft Studio

Bulbgraph.png   Jaspersoft Studio design client is supported since 3.0PR15Q3. For older releases check this section.
Bulbgraph.png   Use Jaspersoft Studio version 6.17.0 from 3.0PR22Q1 onward as it is the recommended version.

You need to download Jaspersoft Studio, a graphical tool that allows you create and modify JasperReports templates (.jrxml files).

Configuring Jaspersoft Studio

Some properties of Jaspersoft Studio need to be modified in order to work properly. In short, you need to make sure:

Bulbgraph.png   Jasperreport can be used in hw manager, but the version should be 1.0.2801 or higher

Setting up Classpath

In Jaspersoft Studio, each report is supposed to be part of a project. So, you first need to create a new project (File > New > Project).

The project has a classpath, and here is where you can add the jars you need.

Creating the Template


Later on we will copy this .jrxml file inside our Openbravo module that is going to keep our Report and the required configuration in the Application Dictionary also.


Now we have to configure the query: we are going to list the products present in the database.


Let's now design the Report Layout


Bulbgraph.png   Note: It is recommended to use Dejavu fonts in jasper reports because this fonts support most of the characters in almost all languages​​. Besides, Dejavu typography is the family of fonts that Openbravo included in jasperreports-fonts library.

Openbravo Runtime Environment

The standard reports in Openbravo (src/org/openbravo/erpReports) make use of several methods that reside inside the Openbravo Runtime Environment, which cannot be executed at design time. For this reason, we provide the following .jar file that encapsulates the following adapted methods of the org.openbravo.erpCommon.utility.Utility Class:

For this, to be able to preview the standard Openbravo reports from JasperStudio, it suffices just to import the .jar file into the classpath of the project within JasperStudio.

Adding images and logos to a report using the ShowImage API

You can use the Image BLOB reference to display an image for a specific report, or one of the Company logos in the application. First you need to add an image object to your report, set the expression class to "java.awt.Image" and the expression image to a call to the ShowImage function of the Utility class (if you want it to display a standard ImageBLOB image reference, that corresponds to a field added to a tab), or to the ShowImageLogo function if you want to display the logo of an Organization or Client.

Images loaded with this method must not have alpha channel. A transparency layer is not supported by the function that loads images in Jasper Reports.

IMAGEID needs to be the UUID of the image you want to show. You could set this value using a Jasper parameter.

ORGANIZATIONID needs to be the UUID of the Organization whose log you want to show. You could set this value using a Jasper argument. An example could be org.openbravo.erpCommon.utility.Utility.showImageLogo("yourcompanydoc", "4387D62C6486481AB3D148442A6AD34E") being 4387D62C6486481AB3D148442A6AD34E the organization ID.

Registering the Report in Application Dictionary

Creating the Report

Bulbgraph.png   This feature is available from 3.0PR15Q2

From 3.0PR15Q2 it is possible to create a report using a process definition. For more information see here.


We must copy the .jrxml template file generated with Jaspersoft Studio into our module. When using Process Definition to generate a Report, templates need to be stored in the web folder of the module. In our example we place it in the following location: /web/org.openbravo.platform.features/jasper


Creating the Menu record



After you have registered the report and menu entry in the Application Dictionary, you need to compile to generated the the necessary code.

ant smartbuild

Once the compilation has completed, refresh your Eclipse project, and restart your tomcat server.

Testing the Report

If you have completed all the steps, you should be able to open your Product List report form the quick-lauch, or menu entry.


Further Details


For information on how JasperReports handles the layout check Making HTML, XLS or CSV friendly reports

Also, a tutorial with the basics of how to design a report can be found here.

Configuring Cell Type in XLS Reports

Starting from 3.0PR15Q3, by default, Openbravo reporting engine exports the XLS data as strings. This is done in order ensure that the exported data can be read after opening the report with the vast majority of spreadsheet applications.

If we want to have a particular format in a cell of our XLS report, and for example, display numbers inside a numeric cell, this default configuration can be overridden at template level.

To override this configuration, the following must be done inside the .jrxml report template:

  1. Add the net.sf.jasperreports.export.xls.detect.cell.type property with true as its value.
  2. Add a pattern for the text field that will be displayed in the XLS cell. With <pattern> tag a fixed pattern can be set and with the <patternExpression> tag it is possible to define a dynamic pattern.

Please note that the decimal and thousands separators used for the numeric cells exported in this way, will be those defined inside the spreadsheet program itself (LibreOffice Calc, Excel,...). An example of report which applies this configuration can be found here.

Creating a Report Using Report and Process

Report and Process window was the habitual way to define reports before PR15Q2, as the Process Definition option was not available. In the following tutorial you can find an example about how to create a Report in this way.

Creating a Reports in old releases

Before 3.0PR15Q3 version, another report design client was used, called iReport.

To get more information about this and further details on reporting in old releases, you can go here.

Report Compilation

Bulbgraph.png   This feature is available starting from 3.0PR18Q3.

When printing a report in the application, it is previously compiled at runtime. The result of this report compilation is cached if there are no modules in in development status.

Besides, it is possible to handle the state of this cache through a JMX extension. Thus, this extension allows to:


Bulbgraph.png   This feature is available starting from 3.0PR19Q2.

It is possible to generate barcodes from JasperReports, using barcode4j or barbecue libraries. These libraries are included in Barcode_generation_in_reports module.

In Platform Features module there is an example of a report making use of different barcode styles, see here the jrxml template.

Migration to JasperReports 6.17.0

Bulbgraph.png   This feature is available starting from 3.0PR22Q1.

When updating from JasperReports 6.0.0, several steps are required to make the JasperReports file behave properly in the 6.17.0 version.

This warning may appear in the 6.0.0 reports when updating: WARNING: The 'isStretchWithOverflow' attribute is deprecated. Use the 'textAdjust' attribute instead.

To fix the warnings, there is a tool provided here. The tool updates all the jasperreports from a provided directory/folder to the updated version 6.17.0.

  1. Clone the repository: git clone
  2. cd jrxmlUpdateTool
  3. Clone or copy the module to update jasperreports from: for example -> cp /path/to/openbravo/modules/moduleWithReports .
  4. Execute: ant update -DreportPath=/path/to/your/reports
  5. All modified reports will be available in jrxmlUpdateTool/build/reports, they keep original file/folder structure. To copy them back to the original folder: cp build/reports/* /path/to/your/reports -r
  6. Check the changes(git status, git diff), then commit and push to the corresponding branch/fork.

Retrieved from ""

This page has been accessed 77,735 times. This page was last modified on 20 November 2023, at 08:31. Content is available under Creative Commons Attribution-ShareAlike 2.5 Spain License.