Posted On

Odoo is great, but its reporting still leaves much to be desired. I don't want to code reports, be it in HTML, CSS or Python.

I want to design them.

I want to be able to drag and drop labels, write a few SQL queries and be done with it, point perfect. Unfortunately, Odoo doesn't allow that, not in an easy enough way.

I have been following Eclipse BIRT closely, and after months of testing, I finally decide to build a connector for Odoo. The idea and approach is heavily inspired by the excellent Pentaho reports for Odoo by WillowIT. We had our preference and I figured that the open source community might like to use an additional tool.

Here is where BIRT connector for Odoo comes in. It's open source and AGPL licensed.

This write up is meant to just be a demonstration, not an in-depth look at the technical side of things. I will be showing you where to download the Docker images, connect a demo Odoo instance (v7 only for now) to the report generator, and run a test BIRT report.

What you need

You should already have this:

  1. Docker
  2. A running instance of PostgreSQL
  3. Git

Steps

First, let's download the BIRT connector and Odoo v7 Docker images that I've put up:

$ docker pull phuihock/birtconn:latest
$ docker pull phuihock/odoo:7.0

I will not use the PostgreSQL Docker image. Instead, I will reuse the PostgreSQL instance that is running on my host machine for this demo. To do that, there are two settings that I must change.

Assuming our Docker containers always run in the 172.17.0.0/16 VLAN (which is the default), we need make sure that our host PostgreSQL also listens on Docker host IP (172.17.42.1) and accepts connections from 172.17.0.0/16.

To do that, edit listen_addresses of /etc/postgresql/9.x/main/postgresql.conf to also listen on 172.17.42.1.

# what IP address(es) to listen on;
# comma-separated list of addresses;
# defaults to 'localhost'; use '*' for all
# (change requires restart)
listen_addresses = 'localhost, 172.17.42.1'  

Next, append the following line to /etc/postgresql/9.x/main/pg_hba.conf

# TYPE  DATABASE        USER            ADDRESS                 METHOD
host    all             all             172.17.0.0/16           md5  

Reload PostgreSQL after that:

$ sudo service postgresql restart

Now, we need a directory to host the BIRT connector addon:

$ mkdir -p birt-demo/{conf,extras}
$ cd birt-demo
$ git clone https://github.com/codekaki/birtconn extras/birtconn

[Edited 2015-09-18 20:57 MYT]phuihock/birtconn contains a birt web application, a simple REST application deployed to a Jetty instance. To setup the JDBC used by the birt webapp, you must pass a series of environment variables into the container:

$ cp extras/birtconn/birt.env.example birt.env
$ vim birt.env  # edit the options as necessary
$ docker run --rm -v `pwd`/extras/birtconn/reports:/opt/birt/reports --env-file birt.env --name birtconn phuihock/birtconn:latest

Next, create a minimal Odoo v7 config file with additional section [birtconn]. Edit other options such as db_user and db_password as necessary.

$ cat >conf/openerp-server.conf<<EOF
[options]
addons_path = openerp/addons,addons,extras/birtconn/addons  
admin_passwd = admin  
db_host = 172.17.42.1  
; db_name =
; db_port = 5432
db_template = template1  
db_user =  
db_password =  
dbfilter = .*  
debug_mode = False  
list_db = True  
log_handler = :INFO  
log_level = info  
logfile = None  
login_message = False  
logrotate = True  
without_demo = True  
xmlrpc = True  
xmlrpc_interface =  
xmlrpc_port = 8069  
xmlrpcs = True  
xmlrpcs_interface =  
xmlrpcs_port = 8071

[birtconn]
api=http://birtconn:8080/birt/api  
EOF  

Now, create and run a phuihock/odoo container linked to the birtconn container:

$ docker run --rm -v `pwd`/conf:/opt/openerp/conf -v `pwd`/extras:/opt/openerp/extras --name openerp -p 8069:8069 --link birtconn:birtconn phuihock/odoo:7.0

An instance of Odoo v7 should be accessible at http://localhost:8069 now.

Create a new database using the database manager with Load demonstration data checked:

Enable Technical Features access rights for user Administrator. Install report_birt addon in Modules / Installed Modules.

The test report should be available at Reporting / BIRT / Test. By clicking menu, you will be presented with a form and parameters, which are dynamically generated based on the report template file extras/birtconn/reports/test.rptdesign.

You can edit the report template with Eclipse BIRT. If you change the report template, the wizard will also change accordingly. Push the 'Print' button to generate the report in 1 of the 3 formats: PDF, XLS and ODS. Other formats can be enabled in the report template itself.

In a later installment, I will demonstrate how we can replace the default purchase report with one of our own.

All steps test runned on Ubuntu 14.04.2, PostgreSQL 9.3 and Docker 1.7.0. If you have found any bugs, do let me know. Pull request are most welcomed!