Odoo中文社区可以通过以下三个域名访问:shine-it.net , odoocn.org,odoo.net.cn

原论坛用户的基本信息和发帖这里都予以保留,请注意:原论坛用户无需重新注册新用户,但是您的密码需要重置

开发人员可以登录gitter讨论组: http://gitter.im/odoo-china/Talk, 需要github账号

如果您登录系统碰到问题,请在微信公众号留言:

OpenERP 关于rml报表的修改



  • 1.rml 报表的组成
        RML报表主要分两部分组成,第一部分是一个在打印目录里面的.py文件,还有.rml的打印文件,这两个文件共同形成了PDF文件。.这两个文件是一样的文件名,不同的扩展名。
      .py文件是一个python程序文件,由它来取数据库的值,并且进行数据计算。
      .rml文件是决定PDF的外观,表格和样式都由rml文件来生成的。一个报表的rml样式由两部分组成,一部分是表头,一部分是内容。分在两个不同的rml文件中,表头文件是一个公共文件。

    2.一个例子讲述rml文件
      下面我以一个POS单来讲述一下rml文件的组成,在代码中,我标记了,每段代码起到的是什么作用。
      为什么以POS单做为例子呢?因为POS单简单,代码少,但具有了rml打印文件的所有部分。
      这个代码已经不是原来的代码了,我已经删除了好多格式文字的代码,以便看的更清楚,事实上,这些代码,只起到装饰作用,做简单的报表,可以不用的。

    <br />&lt;?xml version=&quot;1.0&quot;?&gt;<br />&lt;document filename=&quot;test.pdf&quot;&gt;<br />&nbsp; &lt;template pageSize=&quot;(204.0,842.0)&quot; &lt;!-前面的数字代表打印纸张的大小,这个用数字表示的,也可以用cm表示,比如21cm。-&gt;title=&quot;Receipt&quot; author=&quot;OpenERP S.A. (sales@openerp.com)&quot; allowSplitting=&quot;20&quot;&gt;<br />&nbsp; &nbsp; &lt;pageTemplate id=&quot;first&quot;&gt;<br />&nbsp; &nbsp; &nbsp; &lt;frame id=&quot;first&quot; x1=&quot;0.0&quot; y1=&quot;0.0&quot; width=&quot;204&quot; height=&quot;800&quot;/&gt; &lt;!-这个数字代表的打印内容的大小,纸边界,起始位置,这个位置决定了生成文件后文字的位置,一般要测试才能知道具体位置-〉<br />&nbsp; &nbsp; &lt;/pageTemplate&gt;<br />&nbsp; &lt;/template&gt;<br />&nbsp; &lt;stylesheet&gt;〈!-这个标签是打印样式,表格样式 定义了表格名称,划线,文字的大小等等,可以不定义,表格没有线,文件一样大小-〉<br />&nbsp; &nbsp; &lt;blockTableStyle id=&quot;Standard_Outline&quot;&gt;<br />&nbsp; &nbsp; &nbsp; &lt;blockAlignment value=&quot;LEFT&quot;/&gt;<br />&nbsp; &nbsp; &nbsp; &lt;blockValign value=&quot;TOP&quot;/&gt;<br />&nbsp; &nbsp; &lt;/blockTableStyle&gt; <br />&nbsp; &nbsp; &lt;blockTableStyle id=&quot;Table2&quot;&gt;<br />&nbsp; &nbsp; &nbsp; &lt;blockAlignment value=&quot;LEFT&quot;/&gt;<br />&nbsp; &nbsp; &nbsp; &lt;blockValign value=&quot;TOP&quot;/&gt;<br />&nbsp; &nbsp; &nbsp; &lt;lineStyle kind=&quot;LINEABOVE&quot; colorName=&quot;#000000&quot; start=&quot;1,0&quot; stop=&quot;1,0&quot;/&gt;<br />&nbsp; &nbsp; &nbsp; &lt;!-上面的这行,kind=&quot;LINEABOVE&quot; 决定了表格划线 colorName=&quot;#000000&quot; 决定了表格线的颜色 start=&quot;1,0&quot; stop=&quot;1,0&quot;决定了划线的起止位置,没有这句,表格是没有线的 -&gt;<br />&nbsp; &nbsp; &lt;/blockTableStyle&gt;<br />&nbsp; &nbsp; &lt;blockTableStyle id=&quot;Table4&quot;&gt;<br />&nbsp; &nbsp; &nbsp; &lt;blockAlignment value=&quot;LEFT&quot;/&gt;<br />&nbsp; &nbsp; &nbsp; &lt;blockValign value=&quot;TOP&quot;/&gt;<br />&nbsp; &nbsp; &lt;/blockTableStyle&gt;<br />&nbsp; &nbsp; &lt;blockTableStyle id=&quot;Table10&quot;&gt;<br />&nbsp; &nbsp; &nbsp; &lt;blockAlignment value=&quot;LEFT&quot;/&gt;<br />&nbsp; &nbsp; &nbsp; &lt;blockValign value=&quot;TOP&quot;/&gt;<br />&nbsp; &nbsp; &nbsp; &lt;lineStyle kind=&quot;LINEABOVE&quot; colorName=&quot;#000000&quot; start=&quot;0,1&quot; stop=&quot;0,1&quot;/&gt;<br />&nbsp; &nbsp; &nbsp; &lt;lineStyle kind=&quot;LINEBELOW&quot; colorName=&quot;#e6e6e6&quot; start=&quot;0,-1&quot; stop=&quot;0,-1&quot;/&gt;<br />&nbsp; &nbsp; &nbsp; &lt;lineStyle kind=&quot;LINEABOVE&quot; colorName=&quot;#000000&quot; start=&quot;1,1&quot; stop=&quot;1,1&quot;/&gt;<br />&nbsp; &nbsp; &nbsp; &lt;lineStyle kind=&quot;LINEBELOW&quot; colorName=&quot;#e6e6e6&quot; start=&quot;1,-1&quot; stop=&quot;1,-1&quot;/&gt;<br />&nbsp; &nbsp; &nbsp; &lt;lineStyle kind=&quot;LINEABOVE&quot; colorName=&quot;#000000&quot; start=&quot;2,1&quot; stop=&quot;2,1&quot;/&gt;<br />&nbsp; &nbsp; &nbsp; &lt;lineStyle kind=&quot;LINEBELOW&quot; colorName=&quot;#e6e6e6&quot; start=&quot;2,-1&quot; stop=&quot;2,-1&quot;/&gt;<br />&nbsp; &nbsp; &lt;/blockTableStyle&gt;<br />&nbsp; &nbsp; &lt;initialize&gt;<br />&nbsp; &nbsp; &nbsp; &lt;paraStyle name=&quot;all&quot; alignment=&quot;justify&quot;/&gt;<br />&nbsp; &nbsp; &lt;/initialize&gt;<br />&nbsp; &nbsp; &lt;/stylesheet&gt;<br />&nbsp; &lt;story&gt;&lt;!-story开始就是表格的内容了,oe的数据就调用到这里-&gt;<br />&nbsp; &nbsp; &lt;para&gt;[[ repeatIn(objects,&#039;o&#039;) ]]&lt;/para&gt; &lt;!-para标签调用数据和要显示的文字,这个标签里面的内容就是表格内的内容-&gt;<br />&nbsp; &nbsp; &lt;para&gt;[[o.user_id.company_id.name]]&lt;/para&gt;<br />&nbsp; &nbsp; &lt;para&gt;[[ address and display_address(address)]]&lt;/para&gt;<br />&nbsp; &nbsp; &lt;para&gt;电话 : [[ address and address.phone ]]&lt;/para&gt;<br />&nbsp; &nbsp; &lt;para&gt;收银 : [[ o.user_id.name ]]&lt;/para&gt;<br />&nbsp; &nbsp; &lt;para&gt;超市 : [[ o.shop_id.name ]]&lt;/para&gt;<br />&nbsp; &nbsp; &lt;para&gt;时间 : [[ o.date_order ]]&lt;/para&gt;<br />&nbsp; &nbsp; &lt;para&gt;N° : [[ o.name ]]&lt;/para&gt;<br />&nbsp; &nbsp; &lt;blockTable colWidths=&quot;68.0,68.0,68.0&quot;&gt;&lt;!-一个blockTable标签就是一个表格,colWidths表格的宽度,后来字一个分号代表一个格,还有一个标签 rowHeights表格的高度-&gt;<br />&nbsp; &nbsp; &nbsp; &lt;tr&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &lt;td&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;para&gt;Description&lt;/para&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &lt;/td&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &lt;td&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;para&gt;Qty&lt;/para&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &lt;/td&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &lt;td&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;para&gt;Price&lt;/para&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &lt;/td&gt;<br />&nbsp; &nbsp; &nbsp; &lt;/tr&gt;&lt;!-一个td代表一个格,一个tr代表表格的一行-&gt;<br />&nbsp; &nbsp; &nbsp; &lt;tr&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &lt;td&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;para&gt;[[ repeatIn(o.lines,&#039;line&#039;) ]]&lt;/para&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;para&gt;[[ line.product_id.name ]]&lt;/para&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;para&gt;With a [[ line and line.discount == 0.0 and removeParentNode(&#039;font&#039;) ]] ([[ &#039;%.2f&#039; % line.discount ]]) % discount. &lt;!-百分号是格式化用的%.2f&#039;表示两位小数-&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;/para&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;para&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;font color=&quot;white&quot;&gt; &lt;/font&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;/para&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &lt;/td&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &lt;td&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;para&gt;[[o.state==&#039;cancel&#039; and o.statement_ids and &#039;-&#039; or &#039;&#039;]][&#91;&#039;%.f&#039; % line.qty ]]&lt;/para&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &lt;/td&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &lt;td&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;para&gt;[[o.state==&#039;cancel&#039; and o.statement_ids and &#039;-&#039; or &#039;&#039;]][[ formatLang(net(line.id), currency_obj=company.currency_id) ]] &lt;font face=&quot;Helvetica&quot;&gt;[[ line and line.discount == 0.0 and removeParentNode(&#039;font&#039;) ]] ([[ formatLang(line.discount, currency_obj=company.currency_id) ]])&lt;/font&gt;&lt;/para&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &lt;/td&gt;<br />&nbsp; &nbsp; &nbsp; &lt;/tr&gt;<br />&nbsp; &nbsp; &lt;/blockTable&gt;<br />&nbsp; &nbsp; &lt;blockTable colWidths=&quot;136.0,68.0&quot; style=&quot;Table2&quot;&gt;<br />&nbsp; &nbsp; &nbsp; &lt;tr&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &lt;td&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;para&gt;Taxes :&lt;/para&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &lt;/td&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &lt;td&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;para&gt;[[o.state==&#039;cancel&#039; and o.statement_ids and &#039;-&#039; or &#039;&#039;]][[formatLang(o.amount_tax, currency_obj=company.currency_id)]]&lt;/para&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &lt;/td&gt;<br />&nbsp; &nbsp; &nbsp; &lt;/tr&gt;<br />&nbsp; &nbsp; &lt;/blockTable&gt;<br />&nbsp; &nbsp; &lt;blockTable colWidths=&quot;136.0,68.0&quot; style=&quot;Table4&quot;&gt;<br />&nbsp; &nbsp; &nbsp; &lt;tr&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &lt;td&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;para&gt;Total :&lt;/para&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &lt;/td&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &lt;td&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;para&gt;[[o.state==&#039;cancel&#039; and o.statement_ids and &#039;-&#039; or &#039;&#039;]][[formatLang(o.amount_total, currency_obj=company.currency_id)]]&lt;/para&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &lt;/td&gt;<br />&nbsp; &nbsp; &nbsp; &lt;/tr&gt;<br />&nbsp; &nbsp; &lt;/blockTable&gt;<br />&nbsp; &nbsp; &lt;blockTable colWidths=&quot;102.0,34.0,68.0&quot; style=&quot;Table10&quot;&gt;<br />&nbsp; &nbsp; &nbsp; &lt;tr&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &lt;td&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;para&gt;Payment Mode&lt;/para&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &lt;/td&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &lt;td&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;para&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;font&gt; &lt;/font&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;/para&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &lt;/td&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &lt;td&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;para&gt;Amount&lt;/para&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &lt;/td&gt;<br />&nbsp; &nbsp; &nbsp; &lt;/tr&gt;<br />&nbsp; &nbsp; &nbsp; &lt;tr&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &lt;td&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;para&gt;[[ repeatIn(get_journal_amt(o),&#039;d&#039;) ]]&lt;/para&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;para&gt;[[ d&#91;&#039;name&#039;] ]]&lt;/para&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &lt;/td&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &lt;td&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;para&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;font color=&quot;white&quot;&gt; &lt;/font&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;/para&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &lt;/td&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &lt;td&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;para&gt;[[ formatLang(d&#91;&#039;amt&#039;] or 0, currency_obj=company.currency_id) ]]&lt;/para&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &lt;/td&gt;<br />&nbsp; &nbsp; &nbsp; &lt;/tr&gt;<br />&nbsp; &nbsp; &lt;/blockTable&gt;<br />&nbsp; &lt;/story&gt;<br />&lt;/document&gt;<br />
    


      以上是对rml文件的分析,根据这个分析就能写出自己的rml文件了,但这只是一部分,因为你还不会调用其它数据到rml文件里面来。不过我们能够修改表格去掉不显示的东西,和完全重新画一个新样式的表格了。

    3.报表的表头
      即使这样,我们发现,如果使用系统表头的打印文件,默认的表头,在横线下面有很大一块空白。这样我们就要修改表头的rml文件,修改这个不用找到文件,在软件里就能修改。
      在设置-公司-公司-页眉页脚里时行修改。修改第一项“RML页眉”下面是我修改过的一个例子:

    <br />&lt;header&gt;<br />&nbsp; &nbsp; &lt;pageTemplate&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &lt;frame id=&quot;first&quot; x1=&quot;1.3cm&quot; y1=&quot;3.0cm&quot; height=&quot;21.7cm&quot; width=&quot;19.0cm&quot;/&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &lt;!-上面这段代码表示了带表头打印的宽高,我说的那个空白是由y1=&quot;3.0cm&quot;控制的,是表的打印高度,改成6,文字就上去了,打印的位置比较合适-&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp;  &lt;stylesheet&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;!-- Set here the default font to use for all &lt;para&gt; tags --&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;paraStyle name=&#039;Normal&#039; fontName=&quot;DejaVu Sans&quot;/&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;paraStyle name=&quot;main_footer&quot; fontSize=&quot;8.0&quot; alignment=&quot;CENTER&quot;/&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;paraStyle name=&quot;main_header&quot; fontSize=&quot;8.0&quot; leading=&quot;10&quot; alignment=&quot;LEFT&quot; spaceBefore=&quot;0.0&quot; spaceAfter=&quot;0.0&quot;/&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp;  &lt;/stylesheet&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &lt;pageGraphics&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;!-- Set here the default font to use for all &lt;drawString&gt; tags --&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;setFont name=&quot;DejaVu Sans&quot; size=&quot;8&quot;/&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;!-- You Logo - Change X,Y,Width and Height --&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;image x=&quot;1.3cm&quot; y=&quot;27.7cm&quot; height=&quot;40.0&quot; &gt;[[ company.logo or removeParentNode(&#039;image&#039;) ]]&lt;/image&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;fill color=&quot;black&quot;/&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;stroke color=&quot;black&quot;/&gt;<br /><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;!-- page header --&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;lines&gt;1.3cm 27.7cm 20cm 27.7cm&lt;/lines&gt;&lt;!-这个是表头的线,要保留-&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;drawRightString x=&quot;20cm&quot; y=&quot;27.8cm&quot;&gt;[[ company.rml_header1 ]]&lt;/drawRightString&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;drawString x=&quot;1.3cm&quot; y=&quot;27.3cm&quot;&gt;[[ company.partner_id.name ]]&lt;/drawString&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;place x=&quot;1.3cm&quot; y=&quot;25.3cm&quot; height=&quot;1.8cm&quot; width=&quot;15.0cm&quot;&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;para style=&quot;main_header&quot;&gt;[[ display_address(company.partner_id) or&nbsp; &#039;&#039; ]]&lt;/para&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;/place&gt;&lt;!--phone这段是公司电话吧,可以删除这段话在表头里没啥用--&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;drawString x=&quot;1.3cm&quot; y=&quot;25.0cm&quot;&gt;Phone:&lt;/drawString&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;drawRightString x=&quot;7cm&quot; y=&quot;25.0cm&quot;&gt;[[ company.partner_id.phone or &#039;&#039; ]]&lt;/drawRightString&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;drawString x=&quot;1.3cm&quot; y=&quot;24.6cm&quot;&gt;Mail:&lt;/drawString&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;drawRightString x=&quot;7cm&quot; y=&quot;24.6cm&quot;&gt;[[ company.partner_id.email or &#039;&#039; ]]&lt;/drawRightString&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;lines&gt;1.3cm 24.5cm 7cm 24.5cm&lt;/lines&gt;&lt;!--这个线可以不要,没啥用--&gt;<br /><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;!-- left margin --&gt;&lt;!--这段代码是打印在底下左边的公司版权,那个90好像是文字旋转90度,改打印公司名字就在我加的**那里--&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;rotate degrees=&quot;90&quot;/&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;fill color=&quot;grey&quot;/&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;drawString x=&quot;2.65cm&quot; y=&quot;-0.4cm&quot;&gt;**power by openERP**&lt;/drawString&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;fill color=&quot;black&quot;/&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;rotate degrees=&quot;-90&quot;/&gt;<br /><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;!--page bottom--&gt;&lt;!--这段是打印底下的页码和线,页码计算在这段代码里,自己写的rml代码可以参考这个--&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;lines&gt;1.2cm 2.65cm 19.9cm 2.65cm&lt;/lines&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;place x=&quot;1.3cm&quot; y=&quot;0cm&quot; height=&quot;2.55cm&quot; width=&quot;19.0cm&quot;&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;para style=&quot;main_footer&quot;&gt;[[ company.rml_footer ]]&lt;/para&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;para style=&quot;main_footer&quot;&gt;Contact : [[ user.name ]] - Page: &lt;pageNumber/&gt;&lt;/para&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;/place&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &lt;/pageGraphics&gt;<br />&nbsp; &nbsp; &lt;/pageTemplate&gt;<br />&lt;/header&gt;<br />
    


    4.关于格式化.py文件
      这个文件我还没太弄懂,好像又称做解释器我只发我知道的,我看OE介绍,这个文件主要包括以下代码:

    <br />&nbsp;  import time<br />from report import report_sxw<br /><br />class order(report_sxw.rml_parse):<br />&nbsp; &nbsp; def __init__(self, cr, uid, name, context):<br />&nbsp; &nbsp; &nbsp; &nbsp; super(order, self).__init__(cr, uid, name, context)<br />&nbsp; &nbsp; &nbsp; &nbsp; self.localcontext.update({<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &#039;time&#039;: time,<br />&nbsp; &nbsp; &nbsp; &nbsp; })<br /><br />report_sxw.report_sxw(&#039;report.sale.order&#039;, &#039;sale.order&#039;,<br />&nbsp; &nbsp; &nbsp; &#039;addons/sale/report/order.rml&#039;, parser=order, header=True)<br />
    


        就写到这,关于如何调用数据库数据,等我弄明白了,再给大家写出来,好像得用python代码。
        承德-至阳



  • 写的不对的地方,请大家指正



  • 谢谢分享

    先顶再读



  • 向分享者致敬!



  • 赞......  支持分享....



  • 帮楼主加了

    
    

    标签,这样看起来清楚些。

    xml注释如果用 <!--  --> 这样双中划线括起来应该看起来更清晰些。



  • 再整理一下,一个rml表,主要包括以下几部分:

    第一部分:表的说明

    <br />&lt;?xml version=&quot;1.0&quot;?&gt;<br />&lt;document filename=&quot;test.pdf&quot;&gt;<br />&nbsp; &lt;template pageSize=&quot;(204.0,842.0)&quot; title=&quot;Receipt&quot; author=&quot;OpenERP S.A. (sales@openerp.com)&quot; allowSplitting=&quot;20&quot;&gt;<br />&nbsp; &nbsp; &lt;pageTemplate id=&quot;first&quot;&gt;<br />&nbsp; &nbsp; &nbsp; &lt;frame id=&quot;first&quot; x1=&quot;0.0&quot; y1=&quot;0.0&quot; width=&quot;204&quot; height=&quot;800&quot;/&gt;<br />&nbsp; &nbsp; &lt;/pageTemplate&gt;<br />&nbsp; &lt;/template&gt;<br />
    


    第二部分 表的格式,包括每个表的格线等

    <br />&nbsp; &lt;stylesheet&gt;<br />&nbsp; &nbsp; &lt;blockTableStyle id=&quot;Standard_Outline&quot;&gt;<br />&nbsp; &nbsp; &nbsp; &lt;blockAlignment value=&quot;LEFT&quot;/&gt;<br />&nbsp; &nbsp; &nbsp; &lt;blockValign value=&quot;TOP&quot;/&gt;<br />&nbsp; &nbsp; &lt;/blockTableStyle&gt; <br />&nbsp; &nbsp; &lt;blockTableStyle id=&quot;Table10&quot;&gt;<br />&nbsp; &nbsp; &nbsp; &lt;blockAlignment value=&quot;LEFT&quot;/&gt;<br />&nbsp; &nbsp; &nbsp; &lt;blockValign value=&quot;TOP&quot;/&gt;<br />&nbsp; &nbsp; &nbsp; &lt;lineStyle kind=&quot;LINEABOVE&quot; colorName=&quot;#000000&quot; start=&quot;0,1&quot; stop=&quot;0,1&quot;/&gt;<br />&nbsp; &nbsp; &nbsp; &lt;lineStyle kind=&quot;LINEBELOW&quot; colorName=&quot;#e6e6e6&quot; start=&quot;0,-1&quot; stop=&quot;0,-1&quot;/&gt;<br />&nbsp; &nbsp; &nbsp; &lt;lineStyle kind=&quot;LINEABOVE&quot; colorName=&quot;#000000&quot; start=&quot;1,1&quot; stop=&quot;1,1&quot;/&gt;<br />&nbsp; &nbsp; &nbsp; &lt;lineStyle kind=&quot;LINEBELOW&quot; colorName=&quot;#e6e6e6&quot; start=&quot;1,-1&quot; stop=&quot;1,-1&quot;/&gt;<br />&nbsp; &nbsp; &nbsp; &lt;lineStyle kind=&quot;LINEABOVE&quot; colorName=&quot;#000000&quot; start=&quot;2,1&quot; stop=&quot;2,1&quot;/&gt;<br />&nbsp; &nbsp; &nbsp; &lt;lineStyle kind=&quot;LINEBELOW&quot; colorName=&quot;#e6e6e6&quot; start=&quot;2,-1&quot; stop=&quot;2,-1&quot;/&gt;<br />&nbsp; &nbsp; &lt;/blockTableStyle&gt;<br />&nbsp; &nbsp; &lt;initialize&gt;<br />&nbsp; &nbsp; &nbsp; &lt;paraStyle name=&quot;all&quot; alignment=&quot;justify&quot;/&gt;<br />&nbsp; &nbsp; &lt;/initialize&gt;<br />&nbsp; &nbsp; &lt;/stylesheet&gt;<br />
    


    第三部分,表格内容

    <br /> &lt;story&gt;<br />&nbsp; &nbsp; &lt;blockTable colWidths=&quot;68.0,68.0,68.0&quot;&gt;<br />&nbsp; &nbsp; &nbsp; &lt;tr&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &lt;td&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;para&gt;Description&lt;/para&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &lt;/td&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &lt;td&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;para&gt;Qty&lt;/para&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &lt;/td&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &lt;td&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;para&gt;Price&lt;/para&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &lt;/td&gt;<br />&nbsp; &nbsp; &nbsp; &lt;/tr&gt;<br />&nbsp; &nbsp; &nbsp; &lt;tr&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &lt;td&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;para&gt;[[ repeatIn(o.lines,&#039;line&#039;) ]]&lt;/para&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;para&gt;[[ line.product_id.name ]]&lt;/para&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;para&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;font color=&quot;white&quot;&gt; &lt;/font&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;/para&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &lt;/td&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &lt;td&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;para&gt;[[o.state==&#039;cancel&#039; and o.statement_ids and &#039;-&#039; or &#039;&#039;]][&#91;&#039;%.f&#039; % line.qty ]]&lt;/para&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &lt;/td&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &lt;td&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;para&gt;[[o.state==&#039;cancel&#039; and o.statement_ids and &#039;-&#039; or &#039;&#039;]][[ formatLang(net(line.id), currency_obj=company.currency_id) ]] &lt;font face=&quot;Helvetica&quot;&gt;[[ line and line.discount == 0.0 and removeParentNode(&#039;font&#039;) ]] ([[ formatLang(line.discount, currency_obj=company.currency_id) ]])&lt;/font&gt;&lt;/para&gt;<br />&nbsp; &nbsp; &nbsp; &nbsp; &lt;/td&gt;<br />&nbsp; &nbsp; &nbsp; &lt;/tr&gt;<br />&nbsp; &nbsp; &lt;/blockTable&gt;<br />&nbsp; &lt;/story&gt;<br />&lt;/document&gt;<br />
    


    就是以上三部分控制着一个表格



  • 先占个座再慢慢拜读。。。。



  • 页眉页脚能通过rml文件直接修改吗


  • 管理员



  • 谢谢分享,还没到报表开发阶段呢,先mark



  • 刚接触没几天,正要修个页眉和页脚,看出来点思路来了,谢谢分享