Hi everyone,
I am facing a problem with the custom print format using nested loop for.
The goal for this custom print format is to print item labels for each item in Sales Order according to the quantity. Here is code:
{% for row in doc.items %}
{% for i in range(row.qty) %}
<table width="100%">
<tbody>
<tr>
<td class="kh1">
{{ row.idx }}
</td>
</tr>
<tr>
<td class="kh1" style="font-family: Khmer OS Bokor;">
{{ doc.customer }}
</td>
</tr>
<tr>
<td class="kh1 text-right" style="font-family: Khmer OS;">
{{ row.description }}
</td>
</tr>
</tbody>
</table>
<div class="page-break"></div>
{%- endfor -%}
{%- endfor -%}
But when I use only one for loop, the Print Preview works fine
{% for row in doc.items %}
<table width="100%">
<tbody>
<tr>
<td class="kh1">
{{ row.idx }}
</td>
</tr>
<tr>
<td class="kh1" style="font-family: Khmer OS Bokor;">
{{ doc.customer }}
</td>
</tr>
<tr>
<td class="kh1 text-right" style="font-family: Khmer OS;">
{{ row.description }}
</td>
</tr>
</tbody>
</table>
<div class="page-break"></div>
{%- endfor -%}
Any idea what is wrong with my code?