odoorml

OpenERP RML blockTable Problems


I'm modifying OpenERP Employee Payslip RML Report, I want to Split the line by Earnings or Deductions. This is what I expect as the final result:

 _____________________________ _____________________________
| Earnings                    | Deductions                  |
|                             |                             |
| Description        Amount   | Description        Amount   |
| BASIC               7000.00 | Provident Fund      300.0   |
| House Rent           500.00 | Professional Tax    200.0   |                    
| Conveyance           200.00 |                             |
| Other Allowance      300.00 |                             |
|_____________________________|_____________________________|

But this is what I get when the length for deductions and earnings line are not the same:

 _____________________________ _____________________________
| Earnings                    | Deductions                  |
|                             |                             |
| Description        Amount   |                             |
| BASIC               7000.00 |                             |
| House Rent           500.00 | Description        Amount   |
| Conveyance           200.00 | Provident Fund      300.0   |
| Other Allowance      300.00 | Professional Tax   200.0    |
|_____________________________|_____________________________|

This is my RML:

<blockTable colWidths="270, 270">
  <tr>
    <td><para style="P15">Earnings</para></td>
    <td><para style="P15">Deductions</para></td>
  </tr>
  <tr>
    <td>
      <blockTable colWidths="200.0, 70.0">
        <tr>
          <td>Description</td>
          <td>Amount</td>
        </tr>
      </blockTable>
      <section>
        <blockTable colWidths="200.0, 70.0">
          <para style="P4">[[repeatIn(get_payslip_lines(o.line_ids, 'earnings'),'p') ]]</para>
          <tr>
            <td>[[ p['name'] ]]</td>
            <td>[[ p['amount'] ]]</td>
          </tr>
        </blockTable>
      </section>
    </td>
    <td>
      <blockTable colWidths="200.0, 70.0">
        <tr>
          <td>Description</td>
          <td>Amount</td>
        </tr>
      </blockTable>
      <section>
        <para style="P4">[[repeatIn(get_payslip_lines(o.line_ids, 'deductions'),'d') ]]</para>
        <blockTable colWidths="200.0, 70.0">
          <tr>
            <td>[[ d['name'] ]]</td>
            <td>[[ abs(d['amount']) ]]</td>
          </tr>
        </blockTable>
      </section>
    </td>
  </tr>
</blockTable>

Please advise me for the correct markup.


Solution

  • What you need is to set the vertical alignment of your table cells. You have to use a <blockTableStyle> for this purpose.

    <stylesheet>    
        <blockTableStyle id="T1">
            <blockValign value="TOP"/>
        </blockTableStyle>
    <stylesheet>    
    

    and after that, in your table definition:

    <blockTable colWidths="270, 270"  style="T1">
        <tr>
            <td><para style="P15">Earnings</para></td>
            <td><para style="P15">Deductions</para></td>
        </tr>
        <tr>
            <td>
                <blockTable colWidths="200.0, 70.0">
                    <tr>
                        <td>Description</td>
                        <td>Amount</td>
                    </tr>
                </blockTable>
                <section>
                    <blockTable colWidths="200.0, 70.0">
                        <para style="P4">[[repeatIn(get_payslip_lines(o.line_ids, 'earnings'),'p') ]]</para>
                        <tr>
                            <td>[[ p['name'] ]]</td>
                            <td>[[ p['amount'] ]]</td>
                        </tr>
                    </blockTable>
                </section>
            </td>
    ...