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

Something like:

def onchange_my_o2m(self, cr, uid, o2m_field):
    ....< How to access "o2m_field[0].name", e.g.?>
    return result
 

<field name="my_o2m" on_change="onchange_my_o2m(my_o2m)"/>

What is the structure of the o2m_field in the onchange method?

I first thought it's just a list of ids. But that turned out to be false. And it's certainly not a list of browse_record objects...

I'm currently assuming that it is a list of tuples... [(ID, {field1: ..}), ... ]

 

Thanks for your help.

아바타
취소
베스트 답변

Try the below code:-

def onchange_my_o2m(self, cr, uid, o2m_field):
    if o2m_field:      
        for o2m_value in o2m_field:            
            if o2m_value is dict and 'name' in o2m_value.keys():
                print o2m_value['name']
    return result

아바타
취소
작성자

Sorry, prakash, but I know what to return in the onchange method to change the o2m field. I don't know how to access the one2many field.

Finally, I updated my answer please check it.

관련 게시물 답글 화면 활동
0
3월 15
3216
1
3월 15
5685
2
5월 24
9094
5
5월 24
25169
0
1월 17
8778