Odoo Help

Welcome!

This community is for beginners and experts willing to share their Odoo knowledge. It's not a forum to discuss ideas, but a knowledge base of questions and their answers.

0

What data structure does one2many fields have, when they are passed as arguments in onchange method?

By
René Schuster
on 7/30/14, 5:16 AM 715 views

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.

0

Prakash

--Prakash--
3173
| 5 4 7
Bikaner, India
--Prakash--

OpenERP Devloper at SunARC Technology

Prakash
On 7/30/14, 5:33 AM

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.

René Schuster
on 7/30/14, 5:37 AM

Finally, I updated my answer please check it.

Prakash
on 7/30/14, 7:10 AM

Your Answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

About This Community

This community is for professionals and enthusiasts of our products and services. Read Guidelines

Question tools

1 follower(s)

Stats

Asked: 7/30/14, 5:16 AM
Seen: 715 times
Last updated: 3/16/15, 8:10 AM