Odoo Help

Welcome!

This community 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.

0

[SOLVED]Retrieving the product template linked to a variant selected in treeview

By
Seppe De Roeck
on 11/26/15, 3:15 PM 685 views

Hi all,

In a QWeb report I am trying to retrieve a product template that is the template referenced from a certain selected variant.

As product_tmpl_id is the field on a product variant level referring to the template, I want to fetch the selected variant and then get the linked template.


<!-- GET TEMPLATE DATA BASED ON FIRST SELECTED VARIANT -->

<t t-set="prod_obj" t-value="request.registry['product.template']"/>

<t t-set="var_obj" t-value="request.registry['product.product']"/>

<t t-set="prodvar" t-value="var_obj.browse(request.cr, uid, [('id','=',doc_ids[0])])" />


The prodvar variable is properly set and retrieved.  It returns product.product(('id', '=', 19),) when I select the variant with ID=19

The following line however gives an error :

<t t-set="prodtemp" t-value="prod_obj.browse(request.cr, uid, [('id','=',prodvar.product_tmpl_id)])" />

Also this alternative gives an error :

<t t-set="prodtemp" t-value="prod_obj.browse(request.cr, uid, [('id','=',prodvar.product_tmpl_id.id)])" />


Thanks so much for any tips.  I guess it must be fairly simple to solve but don't seem to find it myself :-)

Seppe

1

Jusab Sida (jsi)

--Jusab Sida (jsi)--
Tiny ERP Pvt Ltd
http://www.odoo.com
874
| 2 1 5
Gandhinagar, India
--Jusab Sida (jsi)--


Jusab Sida (jsi)
On 12/1/15, 2:25 AM

Hi,

You can try this one.

<t t-set="prod_obj" t-value="request.registry['product.template']"/>
<t t-set="var_obj" t-value="request.registry['product.product']"/> 
<t t-set="prodvar" t-value="var_obj.browse(request.cr, request.uid, doc_ids[0])" />

and if you need to search records then search like,

<t t-set="prodtemp" t-value="prod_obj.search(request.cr, request.uid, [('id','=',prodvar.product_tmpl_id.id)])" />

The problem is you are passing Domain in browse method.

Hope this one help you.

0
Seppe De Roeck
On 12/1/15, 3:19 PM

Thanks Jusab,


All clear now and working :-)

tx

Seppe

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 community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

Asked: 11/26/15, 3:15 PM
Seen: 685 times
Last updated: 3/1/16, 6:43 AM