Odoo Help

1

How to display data from an arbitrary model using Qweb ?

By
Najlaâ El Khayat (nel)
on 6/24/14, 3:00 AM 1,391 views

Suppose you'd like to display data from any existing model (custom or not).
How to search on the records you'd like to display? and how to show the values defined on this model ?

1

Search and browse on the object using "request.registry", like this:

 <t t-set-='ids' t-value="request.registry['product.product'].search(request.cr, 1, [('website_published','=',True),('category_id.name','ilike','website')], request.context)">

<t t-set-='prods' t-value="request.registry['product.product'].browse(request.cr, request.uid, ids, request.context)">

           <t t-foreach="prods" t-as="prod" class="col28-set">
                        <span t-field="prod.image" t-field-options="{"widget": "image"}" class="img" />

                       <span t-field="prod.name"/>

           </t>

</t>

For the new API, use "request.env".

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 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: 6/24/14, 3:00 AM
Seen: 1391 times
Last updated: 3/16/15, 8:10 AM