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

Hello,

I would like to print a one2many fields separated by comma, but always I have a comma more.

So how can I use variables in a Qweb loop to avoid this problem?

this is my code :

<span>(
</span>
<span t-foreach="o.hijos_ids" t-as="i">

<span t-field="i.number"/>
<span>,</span>
</span>
<span>)</span>

this is the result:

(nbr1,nbr2,)

Thank you

Best regards

아바타
취소
베스트 답변

<span>(
</span>
<span t-foreach="o.hijos_ids" t-as="i">

<span t-field="i.number"/>
<span t-if="not i.number == o.hijos_ids[-1].number">,</span>
</span>
<span>)</span>

아바타
취소
베스트 답변

if you really want to use qweb for, you can use

t-if='i_last'


but you should probably use python method similar to  

<t t-esc="', '.join(o.hijobs_ids.mapped('number'))"/>
아바타
취소