how to add dynamic empty rows in table with RML code?

我的梦境 提交于 2019-12-12 23:44:01

问题


How can i add empty blank rows in purchase report? and dont know if blank_line is executing perfectly. i followed this link [Openerp purchase report][1] [1]: http://forum.openerp.com/forum/topic8508.html code:

   <section>
  <para style="terp_default_8">[[ repeatIn(o.order_line,'line') ]][[line_no() ]]</para>
    <blockTable colWidths="20.0,100.0,150.0,80.0,50.0,20.0,60.0,50.0" style="Table_Order_Pur_line_Content">
      <tr>[[ blank_line(10) ]]<!--[[ setTag('para','para') ]] -->
      <td>
            <para style="terp_default_9"> </para>
          </td>
          <td>
            <para style="terp_default_9">[[ ', '.join(map(lambda x: x.name, line.taxes_id)) ]]</para>
          </td>
          <td>
            <para style="terp_default_9">[[line.name]]</para>
          </td>
          <td>
             <para style="terp_default_Right_9">[[ formatLang(line.product_qty ) ]]</para>
           </td>
          <td>
            <para style="terp_default_Right_9">[[ formatLang(line.price_unit,digits=get_digits(dp='Product Price') ) ]]</para>
           </td>
             <td>
                <para style="terp_default_Right_9"> </para>
              </td>
         <td>
                <para style="terp_default_Right_9"> </para>
              </td>
         <td>
                    <para style="terp_default_Right_9">[[ formatLang(line.price_subtotal,digits=get_digits(dp='Account'), currency_obj=o.pricelist_id.currency_id ) ]] </para>
            </td>
    </tr>
</blockTable>

[[repeatIn(o.order_line, 'o') ]]

    <blockTable colWidths="20.0,100.0,150.0,80.0,50.0,20.0,60.0,50.0" style="Table_Order_Pur_line_Content_blank">
    <tr> 
         <td> <para style="terp_default_8"><font color="white"> </font></para></td>
         <td> <para style="terp_default_8"><font color="white"> </font></para></td>
         <td> <para style="terp_default_8"><font color="white"> </font></para></td>
         <td> <para style="terp_default_8"><font color="white"> </font></para></td>
         <td> <para style="terp_default_8"><font color="white"> </font></para></td>
         <td> <para style="terp_default_8"><font color="white"> </font></para></td>
         <td> <para style="terp_default_8"><font color="white"> </font></para></td>
         <td> <para style="terp_default_8"><font color="white"> </font></para></td>
    </tr>
      </blockTable> -->
</section>  

回答1:


In your report code (let say order.py) create a method returning a list with the appropriate number of None elements :

def _empty_rows(self, n):
    return [ None for i in range(n) ] 

Expose this method trough the localcontext dictionary in the __init__ method like this:

def __init__(self, cr, uid, name, context):
    ....
    self.localcontext.update( {
        'empty_rows': self._empty_rows,
        ....
    })
    ....

Use it in your RML file (order.rml for ex.) to create the desired number of rows:

   [[ repeateIn(empty_rows(10)) ]] 



回答2:


Why cant you modify the footer and add the total and other fields to footer? Then total will always come at the footer



来源:https://stackoverflow.com/questions/20226100/how-to-add-dynamic-empty-rows-in-table-with-rml-code

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