Odoo Help

Welcome!

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.

1

Qweb's comparison expression

By
thavorac
on 5/11/15, 6:37 AM 1,260 views

Hi, 

I want to write a simple comparison expression in qweb (if age<16 then do something). But unfortunately, i can't use a smaller symbol "<".

 <t t-if="student.age < 16">
do something .......
</t>


Please help!!!

4

Temur

--Temur--
2896
| 6 5 7
Tbilisi, Georgia
--Temur--
Programmer
Temur
On 5/11/15, 7:00 AM

XML has just five special characters, all they has corresponding codes:

 &lt; (<), &amp; (&), &gt; (>), &quot; ("), and &apos; (').

you've to use &lt; xml code of <, from above list:

<t t-if="student.age &lt; 16">
do something .......
</t>

Quite strange though, I can use the normal characters without encoding them. I know its best practice to encode so but still strange that this doesn't work for thavorac.

Yenthe
on 5/11/15, 8:57 AM

maybe it works without encoding in some cases. I tried once to use in odoo domain statement in XML a & symbol as AND operator, it doesn't worked, then reverted back to encoded version: & amp ; and it started working. since I'm using only encoded versions of these 5 characters, to be sure...

Temur
on 5/11/15, 9:46 AM

Guess I'll always use encoding from now on then!

Yenthe
on 5/14/15, 12:17 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

2 follower(s)

Stats

Asked: 5/11/15, 6:37 AM
Seen: 1260 times
Last updated: 5/14/15, 11:42 AM