Dynamic generation of report using RML in OpenERP

4.1k Views Asked by At

How to generate dynamic columns using RML report?

1

There are 1 best solutions below

0
Don Kirkby On

Read through the developer documentation on dynamic content in reports. You can use the repeatIn() function to loop over your dates, but the trick will be adjusting column widths. I suspect you can change the colWidths attribute of the table using the setTag() function.

Here's an example where I used it to change the table style.

    <section>
      [[ repeatIn(lines(data['form'],object=o), 'a') ]]
      <blockTable>
        [[ setTag('blockTable','blockTable',{'colWidths': '80.0,150.0,80.0', 'style': 'Table' + str(a['level'] if a['level'] &lt;= 5 else 5)}) ]] 
        <tr>
          <td lineAboveColor="#000000" lineAboveThickness="5" lineAboveCount="1" lineAboveSpace="5">
            <para style="P10"><font>[[ setTag('font','font',{'face':o.font_style or 'Helvetica', 'color':o.color_font.name or 'black', 'backColor':o.color_back.name or 'white'}) ]] [[ a['code'] ]]</font></para>
          </td>
          <td>
            <para style="P17"><font color="white">[[ '..'*(a['level']-1) ]]</font><font>[[ setTag('font','font',{'face':o.font_style or 'Helvetica', 'color':o.color_font.name or 'black', 'backColor':o.color_back.name or 'white'}) ]] [[ a['name'] ]]</font></para>
          </td>
          <td>
            <para style="P18"><font>[[ setTag('font','font',{'face':o.font_style or 'Helvetica', 'color':o.color_font.name or 'black', 'backColor':o.color_back.name or 'white'}) ]][[ '%.2f'% a['balance'] ]]</font></para>
          </td>
        </tr>
      </blockTable>
    </section>