콘텐츠로 건너뛰기
메뉴
커뮤니티에 참여하려면 회원 가입을 하시기 바랍니다.
신고된 질문입니다
3 답글
8002 화면

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

아바타
취소
베스트 답변

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.

아바타
취소
베스트 답변

Hello All,

Thank you @ Jusab, +1.

For odoo version 11, You can use below code.

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

<t t-set="prodtemp" t-value="prod_obj.search([])" />

<t t-foreach="prodtemp" t-as="prod">

<t t-esc="prod.name"/>

</t>

Hope above code will be helpfully.

Best Thanks,

Ankit H Gandhi.

아바타
취소
작성자 베스트 답변

Thanks Jusab,


All clear now and working :-)

tx

Seppe

아바타
취소
관련 게시물 답글 화면 활동
8
12월 23
22134
1
5월 24
3146
0
7월 17
3608
1
4월 25
1203
2
3월 25
1340