Odoo is the world's easiest all-in-one management software. It includes hundreds of business apps:
CRM | e-Commerce | Accounting | Inventory | PoS | Project management | MRP | etc.
Hello Odoo community,
I have a if statement in the qweb, which when you rollover the object shows the message box which contains that product details, but if product ID is not found message wont be displayed which is correct, but how i can make another if statement saying "product not found" which would be shown only if first if statement is false?
Also i tried to put another if statement outside of <t t-foreach="docs" t-as="o"> tag which kind of worked on product ID which was not found i get the message but the message is displaying on the other products too, details + message ...
<t t-foreach="docs" t-as="o">
<p><strong>Contract Name: </strong><t t-esc="o.contract_name"/></p>
<p><strong>Unit Name: </strong><t t-esc="o.unit_name"/></p>
<p><strong>Unit Area: </strong><t t-esc="o.unit_area"/><t t-esc="o.unit_area_uom"/></p>
<p><strong>Current Rent: £ </strong><t t-esc="o.contract_rent"/></p>
<p><strong>Tenancy Status: </strong><t t-esc="o.tenancy_status"/></p>
<area shape="poly" coords="548,384,607,352,585,493,534,474" alt="TM-D-D-GF-D04" target="TM-D-D-GF-D04" t-att-href="'/web#id=%s&view_type=form&model=account.analytic.account&menu_id=564&action=692' % (o.url)"/>
Any examples, suggestion and help would be appreciated
The QWeb does not contains any structure for else.
So you can use the if - else condition like this:
<t t-if="true == true"> true is true </t>
<t t-if="true == false"> true is not true </t>
QWeb doesn’t have an “else” structure, use a second t-if with the original condition inverted. You may want to store the condition in a local variable if it’s a complex or expensive expression.
Hi, qweb supports the conditional structure for if-else.
CLient: <t t-esc="order.changed.client ? order.changed.client.name : 'Client anyone'"/>
This works same as if-else condition.
You may also check this post:
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.Register
Odoo Training Center
Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.Test it now
|Asked: 3/9/15, 5:26 AM|
|Seen: 2569 times|
|Last updated: 10/24/15, 11:46 AM|