Odoo Help


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

Pascal Tremblay
on 8/9/16, 10:10 PM 2,842 views

Hello there,

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>

Thanks to help!


After the tip of mister Ray Carnes, I have try this one. No success. Syntax error.

                            <tr t-foreach="get_payslip_lines(o.line_ids)" t-as="p">
<td t-if="p.name like '%SUM%'">
<span>IT WORKS!!!!</span>

Vo Tri
On 8/10/16, 2:59 AM


You try:

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

Exactly what I needed! Thanks a lot.

Pascal Tremblay
on 8/10/16, 8:44 AM
Ray Carnes
On 8/9/16, 11:40 PM

Would this work (have not tested)?

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

I test it right now. I come back soon. Thanks a lot.

Pascal Tremblay
on 8/9/16, 11:41 PM

It doesn't seem to work. It is not the first time I meet this problem with t-if in qweb.

Pascal Tremblay
on 8/9/16, 11:50 PM

About This Community

This platform is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

1 follower(s)


Asked: 8/9/16, 10:10 PM
Seen: 2842 times
Last updated: 8/10/16, 8:44 AM