4
votes

How can I add a new header/footer for a report(for example picking list report in delivery order) other than the header/ footer defined in the company?

4

4 Answers

12
votes

In report tag put header='False', eg.

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

it will not print the default header define in the company. then in rml file find <pageTemplate> tag, and replace it with your 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 new header and footer.

1
votes

One way to remove the header is what Atul suggested, 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 might only be generated by a wizard. In that case, you can declare it as a parameter when you register the parser. See the mrp_operations module's barcode report for an example.

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 header using that parameter. It defaults to 'external', but it can be 'internal' or 'internal landscape' to use one of the other headers from the company configuration.

1
votes

You can customize report header in your report.rml file like this,

<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
votes

In report set header = 'False'

Now you can add your own header footer on 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>