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 template: set a variable to an attribute

By
AKRAM M ALFUSAYAL
on 10/26/14, 7:29 PM 1,613 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>
            </xpath>            

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

 

1
AKRAM M ALFUSAYAL
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>

</xpath>

0
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>
</xpath>   

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 community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

Asked: 10/26/14, 7:29 PM
Seen: 1613 times
Last updated: 7/31/15, 12:36 PM