odoo10 report自定义paperformat,就是自定义打印的纸张大小格式等

在report.xml中添加

	<record id="paperformat_euro_qingjia" model="report.paperformat">
        <field name="name">European A4 low margin</field>
        <field name="default" eval="True"/>
        <field name="format">custom</field>
        <field name="page_height">100</field>
        <field name="page_width">100</field>
        <field name="orientation">Portrait</field>
        <field name="margin_top">0</field>
        <field name="margin_bottom">0</field>
        <field name="margin_left">0</field>
        <field name="margin_right">0</field>
        <field name="header_line" eval="False"/>
        <field name="header_spacing">0</field>
        <field name="dpi">80</field>
    </record>

	<report id="action_report_qingjia"
		model="qingjia.qingjiadan"
		string="打印请假单"
		report_type="qweb-pdf"
		name="qingjia.qingjiadan_action_report"
		paperformat="paperformat_euro_qingjia"
	/>
 

record id="paperformat_euro_qingjia" model="report.paperformat"

record id可以改为自己定义的新名字。

model=report.paperformat不要改动,就用这个。 除了添加以上新代码,还需要在__mannifest__.xml中添加 'depends': ['base','report'] 注意这一行改为custom  <field name="format">custom</field> 格式改为custom后,才可以对后续数据进行更改,其余的格式,比如A4,都是有标准数据的。

 
 
report.xml所有代码如下:
<odoo>
	<data>

	<record id="paperformat_euro_qingjia" model="report.paperformat">
        <field name="name">European A4 low margin</field>
        <field name="default" eval="True"/>
        <field name="format">custom</field>
        <field name="page_height">100</field>
        <field name="page_width">100</field>
        <field name="orientation">Portrait</field>
        <field name="margin_top">0</field>
        <field name="margin_bottom">0</field>
        <field name="margin_left">0</field>
        <field name="margin_right">0</field>
        <field name="header_line" eval="False"/>
        <field name="header_spacing">0</field>
        <field name="dpi">80</field>
    </record>

	<report id="action_report_qingjia"
		model="qingjia.qingjiadan"
		string="打印请假单"
		report_type="qweb-pdf"
		name="qingjia.qingjiadan_action_report"
		paperformat="paperformat_euro_qingjia"
	/>

	<template id="minimal_layout" inherit_id="report.minimal_layout">
		<xpath expr="//head" position="inside">
		<link href="/qingjia/static/src/css/report.css" rel="stylesheet"/>
		</xpath>
	</template>

	<template id="qingjiadan_action_report">

		 <t t-call="report.html_container">

			<div class="page">
				 <t t-call="qingjia.main_css"/>
					<table class="test-report">
						<tr class="test-report"><td>名字</td><td>请假天数</td><td>开始日期</td><td>原因</td><td>状态</td></tr>
						<t t-foreach="docs" t-as="o">
						<tr>
							<td><t t-raw="o.name" /></td>
							<td><t t-raw="o.days" /></td>
							<td><t t-raw="o.startdate" /></td>
							<td><t t-raw="o.reason" /></td>
							<td><t t-raw="o.state" /></td>
						</tr>
						</t>
					</table>
			</div>
		</t>
	</template>

	</data>
</odoo>


 
完整的Module代码:http://download.csdn.net/download/qingtianjushi/10129385

引用:https://www.odoo.com/forum/help-1/tag/paperformat-6371/questions
 

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

ensky.

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值