how to add a user defined header in a rml report in openerp?

余生长醉 提交于 2019-12-03 20:16:19

问题


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?


回答1:


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.




回答2:


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.




回答3:


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>



回答4:


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>


来源:https://stackoverflow.com/questions/11947770/how-to-add-a-user-defined-header-in-a-rml-report-in-openerp

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!