Hello I want to use for loop in email template so I created this template with for loop but for some reason, I'm getting an error
Failed to render template
UndefinedError: 'row' is undefined
for some reason, it doesn't recognize sale order lines.
<record id="example_email_template" model="mail.template">
<field name="name">Example e-mail template</field>
<field name="email_from">${object.company_id and object.company_id.email or ''}</field>
<field name="subject">Congratz ${object.name}</field>
<field name="email_to">${object.email|safe}</field>
<field name="lang">${object.lang}</field>
<field name="model_id" ref="model_sale_order"/>
<field name="auto_delete" eval="True"/>
<field name="body_html">
<![CDATA[
<p>Dear ${(object.name)},<br/><br/>
Good job, you've just created your first e-mail template!<br/></p>
Regards,<br/>
${(object.company_id.name)}
<table>
<tbody>
<tr>
<th style="width:135px">Product description</th>
<th style="width: 85px;">Qty </td>
</tr>
% for row in object.order_line:
<tr>
<td> ${row.product_id.default_code}</td>
<td style="text-align: center;">${row.product_uom_qty or ''}</td>
</tr>
%endfor
<tbody>
<table>
]]>
</field>
</record>