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 3,939 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

--Ray Carnes--
| 9 7 9
Keyport, United States
--Ray Carnes--

Senior ERP Analyst

OpenERP 6.1, 7.0; Odoo 8.0, 9.0, 10.0 and 11.0.

Completed Odoo Functional and Technical Training.

Functional Areas:

  • CRM/Sales

  • Inventory

  • Manufacturing

  • Accounting

  • Purchasing

Major Skills:

  • Business Process Reengineering

  • Efficiency Consulting

  • User Needs and GAP Analysis;

  • Functional and Technical Design;

  • Prototyping and Proof of Concepts;

  • Requirements Specifications;

  • Agile Implementation;

  • Data Migration;

  • Configuration & Customization (UI and code);

  • Integration - Odoo and non Odoo Applications and Services;

  • Training and Knowledge Transfer;

  • Go Live Support;

  • Helpdesk;

  • Version Upgrades and Migration.

  • Accounting Expert.

I have over 20 years of experience empowering and enabling users with enterprise information systems that make a real and measurable difference in their ability to proactively manage their businesses and organizations. 

I am a skilled Communicator and I only take the serious things seriously!

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: 3939 times
Last updated: 8/10/16, 8:44 AM