How to use t-if for string odoo?

manu picture manu · Aug 7, 2015 · Viewed 10.4k times · Source

I would like to show the value of the o.employee_id.name variable inside a cell table only when it has a specific value. I tried like this but I get a syntax error:

<t t-if="o.employee_id.name=='naswar'">
    <td>
        <span t-field="o.employee_id.name"/>
    </td>
</t>  

Answer

ChesuCR picture ChesuCR · Aug 7, 2015

Perhaps your syntax error is in other part of the code. If you print a empty cell in order to not break the table structure would be much better. Try this:

<td>
    <t t-if="o.employee_id">
        <t t-if="o.employee_id.name == 'naswar'">
            <span t-field="o.employee_id.name"/>
        </t>
    </t>
</td>