Repeating records
Quick summary
The jasper_reports module can automatically repeat each report record as many times as a specified field indicates. For example, a delivery label can be printed once per package by setting the OPENERP_COPIES_FIELD report property, without custom programming.
Contents
It's quite usual the need of repeating a page several times. For example, you may need to print 4 labels for a given delivery, one per packet. Until now, the only way of creating those four labels using Jasper Reports in OpenERP was by coding it.
Today, the jasper_reports module supports a new property in the report called OPENERP_COPIES_FIELD. If set, the module will repeat each record by the number of times indicated by the field in that property. So if the number of packets was stored in a field called packets you should just set OPENERP_COPIES_FIELD to packets and that's it.
Frequently asked questions
What is OPENERP_COPIES_FIELD used for?
It is a report property that tells jasper_reports which field contains the number of copies to generate for each record.
How can several labels be printed for one delivery?
Store the number of delivery packages in a field and set OPENERP_COPIES_FIELD to that field’s name. The report will repeat the record as many times as the number of packages.
Does the report need custom programming to repeat records?
No. OPENERP_COPIES_FIELD performs the repetition from the configured field’s value, so each copy does not need to be programmed manually.
Related articles
Developer
jasper_reports for Windows
The jasper_reports module version available from Bazaar runs correctly on Windows and only requires Java to be installed. This stable version was planned for inclusion with Koo 5.0.3.
Developer
jasper_reports NG
jasper_reports NG improves report performance by avoiding repeated Java virtual machine starts and making XML-based reports up to 10% faster. It also expands localisation with translatable fields, parameters, plural forms and locale selection, together with tools for extracting and preparing translations.
Developer
Generating Jasper Reports from several models
The article explains how to build Jasper reports that start from one model while displaying related data from another. The solution is to use a subreport and configure the `OPENERP_PATH_PREFIX` property with the path from the main model to the subreport model; in the example, the prefix is `order_line/product_id`.