Reputation: 721
I am facing problem while showing the data from database into Qweb Template of odoo v8.
The codes follows:
The controller gives me object from database : like stock.quant(), the object is from stock_quant table. In this scenario the object is empty. Now i have to check if the object is empty in template. so i tried following :
My Controller: quant.py
quant = { get value from table }
return request.render('test', {'quant':quant})
in my template i have to check if quant is empty or not, so i tried :
<t t-if="quant is Empty" /> # doesn't work
<t t-if="quant is False" /> # doesn't work
also checked other way around
<t t-if="quant is not Empty" /> # doesn't work
<t t-if="quant is not False" /> # doesn't work
Can someone help me in determining how to check object is empty in Qweb Template.
Thanks,
Upvotes: 0
Views: 3874
Reputation: 2431
You using the wrong comparison operator.
In python is
compares identity
, hence if the value is {}
or None
your check will fail even if these values are always boolean falses.
Simply use not quant
and whatever value will be ok.
Upvotes: 1
Reputation: 14746
Just try simply,
<t t-if="not quant">
<!-- your code -->
</t>
And suppose you want to check any other relational fields of that object then you should check like that,
<t t-if="not quant or not 'relational_field_name' in quant">
<!-- your code -->
</t>
Upvotes: 1