Posts Tagged ‘ReportLab’

Installing OpenERP 6.0 RC2 on Ubuntu 10.10

January 3, 2011 10 comments

OpenERP v6.0 RC2 has been released last week and I wanted to test it. This is what I did in my Linux Server, which is running Ubuntu 10.10. The first step is install the required packages, which is done either with Synaptic Package Manager or with the command line as follows:

sudo apt-get install python python-psycopg2 python-reportlab python-egenix-mxdatetime \
python-tz python-pychart python-pydot \ 
python-lxml python-vobject python-setuptools

sudo easy_install PyYaml

The next step is download the OpenERP v6.0 RC2 files from the website, which can be done from the OpenERP website or from the command line:

wget \
wget \
wget \

After downloading the files, unpack them (please, do that in a work directory). Unpacking the files will create three directories. The next step is optional, which is testing the server without installing it. This is done as follows:

cd openerp-server-6.0.0-rc2/bin

If you did not get any warning nor error messages, you are ready to install the server. This is done with the following command:

sudo python install

After installing the server, you will be ready to run it with the command:


The next step is to install the client, which is very similar to installing the server. First we need to check that all the required packages al already installed on the server:

sudo apt-get install python python-gtk2 python-glade2 \
python-matplotlib python-egenix-mxdatetime python-xml python-hippocanvas

You can test the client without installing it. This is almost identical to testing the server:

cd openerp-client-6.0.0-rc2/bin

If you did not get any error message and see the client running smoothly, you will be more than ready to install it. This is done with the following command:

sudo python install

As a final step, if you want to run the client you need to run


from the command line. This is how the client looks like:

I have not installed the web client yet, as soon as I do it I will write about it.


Customizing printed invoices in OpenERP

December 27, 2010 3 comments

These are some things I learnt past week while I was configuring invoices.

Printed invoices in OpenERP are reports. So, if you modify the graphical design of your invoices, such as the logo, all the reports in the system will be modified with the changes you just made. Last week I had to configure the system to print invoices in preprinted forms. To do that I had to remove the header and footer from the invoices, but doing so I modified all the reports I had already created. Until I figured out what to do.

This is what I did. In the administration menu, I selected the Companies->Companies item.


In the companies list you have to select your company and click on the Header/Footer tab. In this tab you will be able to modify the XML code that is printed on every report. You can remove the header by deleting all the lines between the and tags.


This clears the header for the first page of the report. If you would like to remove the header for the inner pages in the report, you have to do the same in the XML code in the Internal Header/Footer tab. This will remove in all the reports the headers, but will not remove the logo. In order to do that, we have to select the General Information tab and remove the logo picture file over there.
After removing the redundant text, we have to generate the report for the invoice. The design of the report can be found in the file system of the server where OpenERP is installed. This design is a XML file named invoice.rml. You can find it in the addons directory. I found it with the following command in my server:
find . -iname invoice.rml
You can edit the file in order to change the layout and the elements printed in the invoice. I recommend making a backup copy before making any changes to the report file. The file format is RML, which stands for (I believe) Report Mark-up Language. It is a mark-up language developed by the development group at ReportLab. You can find more information on this format in this document.
This file has three important markers: template, stylesheet and story. We are interested on two of them, template and story. With the template marker we will describe the report layout, with the story marker we will describe the content itself.For instance, we can define sections for the current date, the customer and its address:
<pageTemplate id=”first”>
<frame id=”date” x1=”13.5cm” y1=”21.5cm” width=”5.5cm” height=”1.2cm”/>
<frame id=”partner” x1=”3.5cm” y1=”18.9cm” width=”15.5cm” height=”1.2cm”/>
<frame id=”address” x1=”4.0cm” y1=”18.0cm” width=”15.0cm” height=”1.2cm”/>


In order to assign text to each section is:

<para style=’body’>31/12/2010</para>
<condPageBreak height=”12″/><para style=’body’>Cristian Sebastian Rocha</para>
<condPageBreak height=”12″/><para style=’body’>Av. Rivadavia 555</para>

We can retrieve the customer information from the system with the following python code:
<para style=’body’>[[ formatLang(o.date_invoice,date=True) ]]</para>
<condPageBreak height=”12″/><para style=’body’>[[ o.partner_id.title or ” ]] [[ ]]</para>
<condPageBreak height=”12″/><para style=’body’>[[ o.address_invoice_id.street ]]</para>
This is more than enough to print on pre-printed invoices forms.