Skip to Content
Menu
This question has been flagged

Hello Community,


I have this line inside a qweb report template:

"strong t-attf-style="#{ o.env.lang === 'en_US' ? 'margin-right: 50px;margin-left: 500px' : 'margin-left: 50px;margin-right: 500px' }">Managing Director /strong"

odoo is complaining about an invalid syntax

Error when compiling xml template SyntaxError: invalid syntax (<>, line 1) Template: 888 Path: /t/t/t[4]/t/div[4]/strong[1] Node: strong t-attf-style="#{ o.env.lang === 'en_US' ? 'margin-right: 50px;margin-left: 500px' : 'margin-left: 50px;margin-right: 500px' }">Managing Director /strong

P.S: the <> are purposely omitted, because the editor thinking it's formatting.


Avatar
Discard
Best Answer

Hello OMAR,

Please find Code in comment. 

I Hope this will Help you. 

Thanks & Regards,
Email: odoo@aktivsoftware.com
Skype: kalpeshmaheshwari 

Avatar
Discard

You can used the code....

<t t-if="o.env.lang === 'en_US'">
<strong style="margin-right:50px;margin-left:500px:margin-left:50px;margin-right:500px;">Managing Director</strong>
</t>
<t t-else="">
<strong>Managing Director</strong>
</t>

Author

Thanks Jainesh for your replay!
unfortunately I'm getting the same error "invalid syntax"

------------------------------------------------------------------------------------------
return compile_handler(el, options, indent)
File "/home/saas15/odoo-15.0/odoo/addons/base/models/qweb.py", line 1013, in _compile_directive_if
code.append(self._indent(f"if {self._compile_expr(expr)}:", indent))
File "/home/saas15/odoo-15.0/odoo/addons/base/models/ir_qweb.py", line 389, in _compile_expr
assert_valid_codeobj(_SAFE_QWEB_OPCODES, compile(namespace_expr, '<>', 'eval'), expr)
File "<>", line 1
values['o'].env.lang === 'en_US'
^
SyntaxError: invalid syntax

Error when compiling xml template
SyntaxError: invalid syntax (<>, line 1)
Template: 888
Path: /t/t/t[4]/t/div[4]/t[1]
Node: <t t-if="o.env.lang === 'en_US'"/>
------------------------------------------------------------------------------------------

I'm pretty sure the "o.env.lang" is set and populated with a value.

Related Posts Replies Views Activity
0
Nov 23
2037
7
Apr 23
26597
1
Apr 24
6039
1
Oct 22
3966
0
Jul 22
9