Odoo Help

1

How to check checkbox state in QWeb report?

By
Yenthe
on 1/2/15, 12:01 PM 4,405 views

Hi everybody

How can I check the state of a checkbox inside a t-foreach of a QWeb report?
The idea is to print the name and number from the same model if the checkbox is checked. 
So far I can loop over the records and I can print out the name & number but now my question is.. how can I write a t-if that checks if the checkbox is checked or not?

Code:

 <t t-if="company.bank_ids" t-foreach="company.bank_ids" t-as="item">
                   <!--This line should check if the checkbox is checked or not..-->
                        <t t-if="item.footer=='True'">
                                <span t-field="item.bank_name"/>
                                <span t-field="item.acc_number"/>
                        </t>
                </t>

If I remove the t-if <item.footer=='True'"> I'll get every line printed. How can I only print the values of the record that has a checkbox set to true?

With kind regards
Yenthe

2

Sudhir Arya (ERP Harbor Consulting Services)

--Sudhir Arya (ERP Harbor Consulting Services)--
11549
| 6 8 8
Ahmedabad, India
--Sudhir Arya (ERP Harbor Consulting Services)--

• Co-Founder & Co-Owner at ERP Harbor Consulting Services

• ERP Consultant / ERP Customization / TechnoFunctional Expert

• Sound knowledge in Python, Odoo (Open ERP), XML, PostgreSQL

• Domain knowledge of Sale Management, Purchase Management, Warehouse Management, Manufacturing, Multi Company Configuration & Management, HR Management, Medical Management, Construction Management, Education Management, Point of Sale, Third Party Integrations

• Positive attitude and quick Learner

• Good analytical skill, quick bug and issue tracing and find the solution

• Good knowledge and experience in payment gateway integration with Odoo

• Ready to accept new challenges

• Active Memeber On Stackoverflow 

LinkedIn

Blog

Stackoverflow

Sudhir Arya
ERP Harbor Consulting Services
skype: 
sudhir@erpharbor.com 
Sudhir Arya (ERP Harbor Consulting Services)
On 1/2/15, 3:53 PM

Hello Yenthe,

Condition you are using is logically wrong. You have given your condition value as a string ('True') not as boolean value.

You can use conditional statements same as python.

It should work like this:

<t t-if="item.footer">
    <span t-field="item.bank_name"/>
    <span t-field="item.acc_number"/>
</t>

If you want to check for False condition:

<t t-if="not item.footer">

Thanks Sudhir this works like a charm! So what if I would want all non-checked checkboxes? I tried with and but none of those seem to work. Could you add that in the answer too? Guess this could help others too. Anyways, I've accepted and upvoted the answer. Thanks!

Yenthe
on 1/3/15, 4:56 AM

They both work perfect. Thank you for adding the False condition Sudhir!

Yenthe
on 1/3/15, 10:29 AM

My pleasure to help you.

Sudhir Arya (ERP Harbor Consulting Services)
on 1/4/15, 6:07 AM

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

Question tools

1 follower(s)

Stats

Asked: 1/2/15, 12:01 PM
Seen: 4405 times
Last updated: 3/16/15, 8:10 AM