Odoo Help


How to get value of one2many fields ?

Ajeng Shilvie
on 1/17/15, 2:40 AM 1,677 views

I make onchange_method in custom module many2one field like this :

    def onchange_branch_collecting(self, cr, uid, ids, branch_id):

        default = {
        wo_pool = self.pool.get('wtc.work.order')
        wo_search = wo_pool.search(cr,uid,[
        workorder = []
        if not wo_search :
            workorder = []
        elif wo_search :
            wo_browse = wo_pool.browse(cr,uid,wo_search)           
            for x in wo_browse :
        default['value'].update({'work_order_ids': workorder})
        return default

and i override create button like this :

    def create(self,cr,uid,vals,context=None):
        print "ini value vals",vals
        wo_collect = []
        for x in vals['work_order_ids']:
        print "ini daftar work order",wo_collect
        collecting_id = super(wtc_collecting_kpb, self).create(cr, uid, vals, context=context)
        if collecting_id :
            print "ada hahahahah"
        wo_pool = self.pool.get('wtc.work.order')
        wo_search = wo_pool.search(cr,uid,[
        wo_browse = wo_pool.browse(cr,uid,wo_search)
        print "ini ajeng"            
        for y in wo_browse :
            for z in wo_collect :
                if z['name'] == y.name :   #this condition is error 
        return collecting_id

the problem is  , i want to get value name in wo_collect  . But still not work error message show up it said not mathing apples and orange .


Try to debug/print the value of z['name']. It gives the feeling that "type" of both operands i.e z['name'] and 'y.name' is different. That means the datatype of both the values that you are tyring to compare is different.

yes you were right , i found the answer thanks

Ajeng Shilvie
on 1/17/15, 8:16 AM

About This Community

This platform 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.


Odoo Training Center

Access to our E-learning platform and experience all Odoo Apps through learning videos, exercises and Quizz.

Test it now

Question tools

1 follower(s)


Asked: 1/17/15, 2:40 AM
Seen: 1677 times
Last updated: 3/16/15, 8:10 AM