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.

0

t-att-dir refused to set

By
AKRAM M ALFUSAYAL
on 8/8/15, 3:37 PM 644 views

I have this template

<?xml version="1.0" encoding="utf-8"?>

<openerp>

<data>

<template id="web_rtl.layout" inherit_id="web.layout" name="RTL Layout">

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

<t t-set="langs" t-value="env['res.lang']"/>

<t t-set="lang_dir" t-value="langs.search([('code', '=', env.lang)], limit=1).direction"/>

<attribute name="t-att-dir">lang_dir</attribute>

</xpath>

<xpath expr="//html/head/t" position="after">

<t t-set="langs" t-value="env['res.lang']"/>

<t t-set="lang_dir" t-value="langs.search([('code', '=', env.lang)], limit=1).direction"/>

<link t-if="lang_dir == 'rtl'" href="/web_rtl/static/src/css/bootstrap-rtl.css" rel="stylesheet"/>

<link t-if="lang_dir == 'rtl'" href="/web_rtl/static/src/css/rtl.css" rel="stylesheet"/>

</xpath>

</template>

</data>

</openerp>


The second xpath works fine, but the first one does not set anything to the dir attribute as if you do this

<attribute name="t-att-dir"></attribute>  which results <html>


if I do this:

<attribute name="t-att-dir">1+1</attribute>

the template result <html dir=2> and if I use t-if and t-attf-dir to set the attribute does not work


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

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

both if statements true and dir= the last if statment executed although lang_dir in the second xpath works fine.


Can some one help me on this

Best regards

Akram

0
AKRAM M ALFUSAYAL
On 8/9/15, 9:00 PM

Some odd thing is happening in this code but If I change 


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

<t t-set="langs" t-value="env['res.lang']"/>

<t t-set="lang_dir" t-value="langs.search([('code', '=', env.lang)], limit=1).direction"/>

<attribute name="t-att-dir">lang_dir</attribute>

</xpath>


to 


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

<attribute name="t-att-dir">env['res.lang'].search([('code', '=', env.lang)], limit=1).direction</attribute>

</xpath>


Then code works fine.

Any explanations would be appreciated 

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: 8/8/15, 3:37 PM
Seen: 644 times
Last updated: 8/9/15, 9:01 PM