Odoo Help


This community 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.


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

Pascal Tremblay
on 8/9/16, 10:10 PM 804 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
Greater Los Angeles, United States
--Ray Carnes--

Senior Odoo Analyst

OpenERP 6.1, 7.0 and Odoo 8.0, 9.0 (Since 2012)

Completed Functional and Technical Training.

Major Skills:

  • Needs Discovery and Requirements Analysis;

  • Function and Technical Specifications;

  • Project Planning;

  • Prototyping and Proof of concepts;

  • Data migration;

  • Configuration & Customization (UI and modules);

  • Integration - data, business logic and service levels;

  • Training and Knowledge transfer;

  • Go Live support;

  • Help desk;

  • Version Migration.

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. 

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

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)


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