Developer

Repeating records

1 min read

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.