In my modified purchase_requisition report, I want the table of line_ids to contains 8 table row, so I try to add an empty table according to the number of line_ids. For example, if the line_ids contain only one product, therefore, I have to add more 7 empty table below. This way, I can fix the table height up to 8 rows.
The procedure I try is write a python method to generate an empty table dynamically. However, it doesn't generate the empty table that I want. Please help me. Here's my code:
requisition.py
class requisition(report_sxw.rml_parse):
def __init__(self, cr, uid, name, context):
super(requisition, self).__init__(cr, uid, name, context=context)
self.localcontext.update({
'time': time,
'empty_table': self.empty_table,
})
def empty_table(self, line_id):
if len(line_id) < 8:
for i in range(8 - len(line_id)):
table += """<blockTable rowHeights="1cm" colWidths="1.5cm,9.5cm,3.0cm,1.5cm,1.5cm" style="table_info">
<tr>
<td><para style="table_info_num"> </para></td>
<td><para style="table_info_text"> </para></td>
<td><para style="table_info_num"> </para></td>
<td><para style="table_info_num"> </para></td>
<td><para style="table_info_num"> </para></td>
</tr>
</blockTable>"""
return table
purchase_requisition.rml
<section>
[[ repeatIn(requisition.line_ids,'line_ids') ]]
<blockTable rowHeights="1cm" colWidths="1.5cm,9.5cm,3.0cm,1.5cm,1.5cm" style="table_info">
<tr>
<td><para style="table_info_num"><seq id="number"/></para></td>
<td><para style="table_info_text">[[ line_ids.product_id.name ]]</para></td>
<td><para style="table_info_num">[[ repeatIn(line_ids.partner_ids,'partner') ]] [[ partner.name ]]</para></td>
<td><para style="table_info_num">[[ line_ids.product_qty ]]</para></td>
<td><para style="table_info_num">[[ line_ids.product_uom_id.name ]]</para></td>
</tr>
</blockTable>
</section>
[[ empty_table(requisition.line_ids) ]]