Odoo Help

0

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

By
Pascal Tremblay
on 8/9/16, 10:10 PM 2,212 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>
</div>


Thanks to help!


EDIT #1

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>
</td>
    
.......



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

Hi,

You try:

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

Exactly what I needed! Thanks a lot.

Pascal Tremblay
on 8/10/16, 8:44 AM
0
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>
</div>

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.

Register

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)

Stats

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