Defining Template Directives
Syntax for defining template directives is a combination of Genshi template language and Python code. Still, even if you are not familiar with any of them, it is easy to create simple templates. Syntax of directives is all the same in all possible template types (OpenOffice.org Writer - odt, OpenOffice.org Calc – ods).
There are several options, to define template directives. Because of OOo program specificity, not all of them can be used in all template types. Mainly there are three options (you may want to call them containers) to insert directives into template.
Text Placeholder fields
The most common and widely used option is to use “Text Placeholder fields”. In order to insert this this type of container, you have to text placeholder field from menu “Insert/Fields/Other...”. In “Type” list select “Placeholder”, “Format” list select “Text”. In “Placeholder” field write the template directive. In “Placeholder” field write the directive. Then press “Insert” button – placeholder with specified directive will be placed at the position where the cursor was at the moment.
Unfortunately there is no Text Placeholder Field for OOo Calc document. This is why an alternative container has been chosen - “Hyperlink” field. Although you can not use placeholder on spreadsheet document template, all the syntax of directives remains the same. Menu “Insert/Hyperlink...” opens a dialog that enables you to create and edit hyperlinks. Select “Internet” as hyperlink type. In “Target” field write the directive, just like you would do for placeholder. Only difference is, that you have to prepend the directive with text “python://“ (“relatorio://” using legacy report_openoffice module). As directives may be pretty long, you may want to use “Text” field below for shorter representation of field on document – a preview. Armed by these two types of containers, you are enough to place any directive on any template, that is supported by OpenOffice.org templating engine for OpenObject (OpenERP).
Still if you look at both types more carefully, you would notice one major advantage and one disadvantage of hyperlinks over placeholders. Advantage is that hyperlinks may be represented with preview value, which is good for better estimating space required for text. Still it is harder to change the code. If you eventually would click on hyperlink, you would be redirected to hyperlink code as it would be ordinary Internet hyperlink.
To have advantage of preview values and overcome problems of redirection, another type of field, has been chosen - “Input field”. This field can be used on OOo Writer templates. Steps to place this container is similar to placeholder – use menu “Insert/Fields/Other...”. In “Type” list select “Input field”, and in “Reference” field write directive, just as you would for placeholder field. The only difference, you have to remember, is that you have to embrace the directive inside “<>”.
Still one question remains, how to place images on document? For placing images on templates, another method have been chosen – frames. Frames resemble more or less the same parameters as images, they have dimensions and same placement properties.
For inserting an image into template, you have to add ordinary OpenOffice.org frame to document and write directive into frame's properties. To place frame on a template you use “Insert/Frame...” menu.
In the form, that opens, select “Options” tab and write directive in “Name” field. Remember in order to let reporting engine know that this frame should be replaced with image, you have to add “image: ” in front of the directive. Following example directive places logo of the company.
You do not have to add another “image: ” to this directive. Directive have to be placed in frame's properties “Name” field, not directly inside frame as a text.