OpenOffice Report Designer for OpenERP

OpenOffice / Libre Office Report Designer plug-in

Introduction

This is quite quite easy to get running 'Out-the-Box' but needs quite a bit of fiddling around to build new reports working. As with all the print solutions, it depends on a print engine to convert and merge data into a form. It uses RML templates that are created in OpenOffice / OpenLibre Office as .sxv format documents. These are converted from .sxc to .rml files using a converter called SXW2RML. The RML files are used by OpenERP's report engine to combine data with the form which in turn creates the .pdf document.  OpenOffice / OpenLibre requires a extension interface with the OpenERP reports. The plug-in is nicely provided by the module installation as a .zip file.  


https://doc.openerp.com/doc_static/6.0/_images/ooo_report_overview.png
/doc_static/6.0/_images/ooo_report_overview.png




From the inside of OpenERP it looks like this :

https://doc.openerp.com/doc_static/6.0/_images/process_ooo.png
/doc_static/6.0/_images/process_ooo.png


From within OpenOffice / Libre Office any of the existing reports can be extracted from OpenEPR where they can be edited and then 'sent' back to the server with the same name or a new name (but to the openerp database and not to the file system). 

The main challenge with this solution is getting your head around the graphics and code. You'll also need to understand  Python. and creation of  rml parsers to extract repeating child records, such as the BOM of a BOM componentBut then all the other solutions I tested,  also requires you get your head some degree of programming. In some cases I prefer just editing the raw .rml file directly (see details below), which is a bit like java script found in processing.org.  Perhaps I'll build a graphical representation directly one day.

But in many cases if only simple and small modification are required then this should be a solution to get you up and running quickly.    

In your template you must be sure to put also the text you will change, to format it to your needs. To use it in a django app, you can use the django template system placeholders like {{name}} or {{address}}.

Then, save it and use Openerp SXW2RML to transform it to RML.

./openerp_sxw2rml.py template.odt > template.rml

You can use python-trml2pdf to see the results:
apt-get install python-trml2pdf

and then
trml2pdf template.rml > template.pdf

If it’s good, you can simply replace placeholders with the text of your report (or packing slip, as we’ve done) and then generate your pdf. Using them on django apps makes RML a very good choice to generate automatically documents from databases and web apps.


  • [[ repeatIn(objects,'o') ]] : Loop on each objects selected for the print
  • [[ repeatIn(o.invoice_line,'l') ]] : Loop on every line
  • [[ repeatIn(o.invoice_line,'l', 'td') ]] : Loop on every line and make a new table cell for each line.
  • [[ (o.prop=='draft')and 'YES' or 'NO' ]] : Print YES or NO according the field 'prop'
  • [[ round(o.quantity * o.price * 0.9, 2) ]] : Operations are OK.
  • [[ '%07d' % int(o.number) ]] : Number formatting
  • [[ reduce(lambda x, obj: x+obj.qty , list , 0 ) ]] : Total qty of list (try "objects" as list)
  • [[ user.name ]] : user name
  • [[ setLang(o.partner_id.lang) ]] : Localized printings
  • [[ time.strftime('%d/%m/%Y') ]] : Show the time in format=dd/MM/YYYY, check python doc for more about "%d", ...
  • [[ time.strftime(time.ctime()[0:10]) ]] or [[ time.strftime(time.ctime()[-4:]) ]] : Prints only date.
  • [[ time.ctime() ]] : Prints the actual date & time
  • [[ time.ctime().split()[3] ]] : Prints only time
  • [[ o.type in ['in_invoice', 'out_invoice'] and 'Invoice' or removeParentNode('tr') ]] : If the type is 'in_invoice' or 'out_invoice' then the word 'Invoice' is printed, if it's neither the first node above it of type 'tr' will be removed.

Editing RML files in OpenERP 7 directly

It is well worth considering editing the reports directly into the RML file.  Admittedly it's not  so easy to interpret what the form looks like, but for an advanced programmer this is usually easier (long term) and offers more flexibility. Read the following section for more details ->  RML reports 

If you forget the openerp master or database password this is stored in the  ~/.openerp_serverrc file or the openerp-server.config file


Refs & eBooks:
Videos:
Comments