Home > Financial Accounting > Customizing printed invoices in OpenERP

Customizing printed invoices in OpenERP

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.

<header>
</header>

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”/>
</pageTemplate>

 

In order to assign text to each section is:

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

We can retrieve the customer information from the system with the following python code:
<story>
<para style=’body’>[[ formatLang(o.date_invoice,date=True) ]]</para>
<nextFrame/>
<condPageBreak height=”12″/><para style=’body’>[[ o.partner_id.title or ” ]] [[ o.partner_id.name ]]</para>
<nextFrame/>
<condPageBreak height=”12″/><para style=’body’>[[ o.address_invoice_id.street ]]</para>
</story>
This is more than enough to print on pre-printed invoices forms.
Cheers!
Advertisements
  1. John Lamarq
    February 18, 2011 at 7:56 pm

    Hello, I think there is a much simpler way to do this: Aeroo reports.

  2. bharati soopal
    March 11, 2011 at 1:17 pm

    Hello

    I am amending the invoice rml file, oh god I’m facing lots of problem. I have to print on pre-printed forms, the header and footer is not appearing….kindly advise

    • developingmoldeo
      March 15, 2011 at 5:08 pm

      sorry for taking me so long to reply. Have you tried the openerp forums? or the IRC chat? you will find the answer over there
      hope this helps,

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: