轉載請注明原文地址: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>
