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

Hello everyone.

Can anyone know, how to display customized many2one field as selection field in website shopping cart. Please share the ideas(also code).Thanks in advance

아바타
취소

dear vadivel,

If i understood you right , I think you need to add widget="selection" on your many2one field.

I hope I helped you.

베스트 답변

Try it...

Pass all model  objects of the many2one field to the template.

then ...

<select>

    <t t-foreach="all_objects" t-as="each_objects">
        <option>

            <t t-esc="each_objects.name"/>
         </option>
     </t>

</select>    


아바타
취소

Don't forget to close the <t>-Tag with </t>.

tank u , i shall ...

베스트 답변

Does anybody know how to "Pass all model  objects of the many2one field to the template.", see answer of "Odoo developer". I could not find an easy way. I could grap the model in the controller via env() and then try to fetch all records in a for loop or something like that but there must be a simpler "odoonic" way to do this, I guess.

(As the questions is old, I am using Odoo 11)

(I would have done a comment but I am  not allowed)

Thanks 

Ok, figured it out myself:

put this in the controller

all_objects = request.env['model.name'].search([])
values = {
"some_values": some_values,
"all_objects": all_objects
}
return request.render(template_name, values)
아바타
취소
관련 게시물 답글 화면 활동
1
1월 22
2889
0
1월 24
1068
1
11월 15
12059
1
3월 15
8511
0
3월 15
3564