Odoo报表的report标签和报表格式定义

转载请注明原文地址:https://www.cnblogs.com/ygj0930/p/10826329.html

一:Report标签

    report标签可用于定义一条报表记录。属性有:

        1)id

        生成的数据的id。

        2)name (必选)

        报表名,用于查找及描述。

        3)model (必选)

        报表记录所对应的模型。

        4)report_type (必选) 

        qweb-pdf| qweb-html

        5)report_name

        输出pdf时文件名。

        6)groups

        用于指定可以查看、使用该报表的用户组。

        7)attachment_use

        如果设置为true时,该报表会以记录的附件的形式保存,一般用于一次生成、多次使用的报表。

        8)attachment

        用于定义报表名的python表达式,使记录可以通过object对象访问。

        9)paperformat 

        用于打印报表的文件格式的外部id(默认是公司的格式)(可以自定义格式)。

        例子:

<report
    id="account_invoices"
    model="account.invoice"
    string="Invoices"
    report_type="qweb-pdf"
    name="account.report_invoice"
    file="account.report_invoice"
    attachment_use="True"
    attachment="(object.state in ('open','paid')) and
        ('INV'+(object.number or '').replace('/','')+'.pdf')" //拼接文件名
/>

二:报表格式

        报表格式用report.paperformat记录来定义,字段有:

        1)name (必选)

        用于查找及区分的名字。

        2)description

        格式的描述。

        3)format

        一个预定义的纸张大小格式如(A0-A9,B0-B10等)或自定义custom,默认是A4。

        4)dpi

        输出的DPI,默认90。

        5)margin_top, margin_bottom, margin_left, margin_right

        以 mm 为单位的margin值。

        6)page_height, page_width

        以  mm  为单位的页面宽高尺寸值。

       7)orientation

        纸张横向或纵向打印。

        8)Landscape , Portrait header_line 

        boolean类型,是否显示标题行。

        9)header_spacing

        以 mm  为单位的头部空白尺寸。

     例子:

<record id="paperformat_frenchcheck" model="report.paperformat">
    <field name="name">French Bank Check</field>
    <field name="default" eval="True"/>
    <field name="format">custom</field>
    <field name="page_height">80</field>
    <field name="page_width">175</field>
    <field name="orientation">Portrait</field>
    <field name="margin_top">3</field>
    <field name="margin_bottom">3</field>
    <field name="margin_left">3</field>
    <field name="margin_right">3</field>
    <field name="header_line" eval="False"/>
    <field name="header_spacing">3</field>
    <field name="dpi">80</field>
</record>
原文地址:https://www.cnblogs.com/ygj0930/p/10826329.html