Home > Enterprise >  calculating in odoo xml view
calculating in odoo xml view

Time:11-02

is it possible to calculate variables in odoo(direct in the xml template)?

Example:

<field name="price"/>
<field name="log"/>

if price > 20
do something

if price <= 20
do something

or

price   log
do something

I‘ll calculate direct in the xml template.

Are operators available in the xml view? For example, plus, minus, greater than, less than, etc.? I could read something in the documentation regarding qweb, however that does not work for me.

a quick example…

<t t-if="price > 20"> do something ....... </t>

and then translate the > into special characters like > - because xml has problems to read the > - but this does not work for me…

Thanks a lot for your support!

CodePudding user response:

You can use &lt; (<), &amp; (&), &gt; (>) in the xml template.

<t t-if="price &gt; 20"> do something ....... </t>
  • Related