Search code examples
conditional-statementsqweb

How to use t-if condition in qweb to detect a field contains a string?


I'm working in Odoo 8.

In a qweb report, does it exist a operator to detect if a field contains a particular string?

Example :

<div t-if="p.name **contains** 'SUM'">
    <p>bla bla bla</p>
</div>

Thanks to help!


Solution

  • You can use 'in' operator to check whether field contains a particular string or not.

    <div t-if="'SUM' in p.name">
        <p>bla bla bla</p>
    </div>
    

    p.name == 'SUM' will check exact name = SUM, to check portion of string in field 'in' operator is useful.