Odoo Help


Qweb template: set a variable to an attribute

on 10/26/14, 7:29 PM 1,697 views

I am trying to output ltr/rtl variable lang_direction in qweb tamplate like this:

            <xpath expr="//html" position="attributes">
                <attribute name="dir"><t t-esc="lang_direction"/></attribute>

This is not working. Is there a way to do it?


On 7/31/15, 12:36 PM

I used t-att-$name instead of t-attf

So it should be

<xpath expr="//html" position="attributes">

        <attribute t-if="lang_direction == 'ltr'" name="t-attf-dir">ltr</attribute>

        <attribute t-if="lang_direction == 'rtl'" name="t-attf-dir">rtl</attribute>


Nedas Zilinskas
On 3/10/15, 6:52 AM

Hello Akram,

What about a workaround like the following:

<xpath expr="//html" position="attributes">
        <attribute t-if="lang_direction == 'ltr'" name="dir">ltr</attribute>
        <attribute t-if="lang_direction == 'rtl'" name="dir">rtl</attribute>

Can we only set an attribute with xpath? Can we set it directly?

Pascal Tremblay
on 9/22/15, 6:36 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 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: 10/26/14, 7:29 PM
Seen: 1697 times
Last updated: 7/31/15, 12:36 PM