Skip to Content
Meniu
Trebuie să fiți înregistrat pentru a interacționa cu comunitatea.
Această întrebare a fost marcată
1 Răspunde
4366 Vizualizări

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.

Imagine profil
Abandonează
Cel mai bun răspuns

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

Imagine profil
Abandonează
Autor

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.

Related Posts Răspunsuri Vizualizări Activitate
0
mar. 15
3218
1
mar. 15
5686
2
mai 24
9099
5
mai 24
25176
0
ian. 17
8782