I want to add a sidebar or a header to some of my reports in OpenERP. The ReportLab user manual (PDF), describes the <frame>
and <nextFrame>
tags. Are they fully supported in OpenERP? I've gotten some things to work, but one frame just flows into the next, so a report that takes more than one page ends up with overlapping text.
After a bunch of digging in the code, I have frames working in OpenERP 5.0. The key feature I had to find was the last="true"
attribute for a frame definition. That means that the frame should assume it's the last frame on the page. Any text that overflows it will flow to the first frame of a new page, not to the next frame on the current page. I ended up setting it true on all my frames. To see an example with frames, here are some snippets from our balance sheet report.
<template
pageSize="(8.5in,11in)"
title="Test"
author="Zaber Technologies Inc."
allowSplitting="20">
<pageTemplate id="first">
<frame
id="first"
x1="1.3cm"
y1="0.2cm"
height="27.5cm"
width="14.0cm"
last="true"/>
<frame
id="upper_right"
x1="14.1cm"
y1="21.53cm"
height="5.2cm"
width="5.0cm"
last="true"/>
</pageTemplate>
</template>
This section specifies your page layout. By default, text will start in the first frame in the list. y1
is the distance from the page bottom. You can specify a page template in two places: within the report itself, or within the headers defined in the company configuration. If you use a header, the report's first page template will be replaced by the header's page template, so the report's template can just be a pageTemplate
tag with an empty frame
tag in it. The company headers can only use one page template, but each report can define more than one page template.
When you want to put something in one of the other frames, use setNextFrame
and nextFrame
.
<setNextFrame name="upper_right"/>
<nextFrame/>
You don't have to use the frames in order. You can switch to an earlier frame in the list, and it won't start a new page.
For more details about changing the header, see the documentation or the question on user-defined headers.