How to add custom header to rml report in openerp?

How to add a new header / footer for the report (for example, collecting the list in the order of delivery), except for the header / footer defined in the company?

+4
source share
4 answers

In the report tag put header = 'False', for example.

<report header='False' auto="False" id="report_product_history" model="product.product" name="stock.product.history" string="Stock Level Forecast"/> 

he will not print the default header definition in the company. then in the rml file find the <pageTemplate> and replace it with rml code. eg.

  <template pageSize="(595.0,842.0)" title="Test" author="Atul Makwana" allowSplitting="20"> <pageTemplate id="first"> ***Your rml header & footer*** </pageTemplate> </template> 

This way you can put a new header and footer.

+11
source

One way to remove the header is that Atul suggested to declare it in the report tag.

 <report header="False" auto="False" id="report_product_history" model="product.product" name="stock.product.history" string="Stock Level Forecast"/> 

In some situations, there is no report tag. For example, a report can only be created by a wizard. In this case, you can declare it as a parameter when registering the parser. For an example, see the mrp_operations barcode report module.

 class code_barcode(report_sxw.rml_parse): def __init__(self, cr, uid, name, context): super(code_barcode, self).__init__(cr, uid, name, context=context) self.localcontext.update({ 'time': time, }) report_sxw.report_sxw('report.mrp.code.barcode', 'mrp_operations.operation.code', 'addons/mrp_operations/report/mrp_code_barcode.rml', parser=code_barcode, header=False) 

You can also specify a specific title using this parameter. By default, it is equal to 'external' , but it can be either 'internal' or 'internal landscape' use one of the other headers from the company configuration.

+1
source

You can customize the report title in the report.rml file as follows:

 <pageTemplate id="first"> <frame id="first" x1="57.0" y1="115.0" width="481" height="615"/> <header> <pageGraphics> <image x="1.3cm" y="26.0cm" height="90.0">[[company.logo or removeParentNode('image')]]</image> <drawString x="10.9cm" y="2.9cm">Signature:</drawString> <drawString x="12.7cm" y="2.9cm">___________________________________</drawString> </pageGraphics> </header> </pageTemplate> 
+1
source

In the header of the report set = 'False'

Now you can add your own header on the page

 <template title="Test" author="Sagar" allowSplitting="20"> <pageTemplate id="first"> <frame id="first" x1="15.0" y1="42.0" width="539" height="758"/> <pageGraphics> <!-- ================== Header =============== --> <image x="14cm" y="25.6cm" height="40.0">[[ company.logo or removeParentNode('image') ]]</image> <setFont name="Helvetica" size="10.0"/> <drawString x="1cm" y="27.2cm">Main Header</drawString> <!-- Order Details --> <place x="33" y="18cm" width="530.0" height="205.0"> <blockTable colWidths="265,265" style="Table1"> <tr> <td>Header Value 1</td> <td><para style="normal2-center">Header Value 2</para></td> </tr> </blockTable> </place> <!-- ======================== footer =========================== --> <place x="33" y="55cm" width="530.0" height="205.0"> <blockTable colWidths="265" style="Table1"> <tr><td><para style="normal2-center">Footer Value</para></td></tr> </blockTable> </place> </pageGraphics> </pageTemplate> </template> 
+1
source

All Articles