This question has been flagged
1 Reply
6177 Views

I make onchange_method in custom module many2one field like this :

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

        default = {
            'value':{},
        }
        
        wo_pool = self.pool.get('wtc.work.order')
        wo_search = wo_pool.search(cr,uid,[
                                    ('branch_id','=',branch_id),
                                    ('kpb_collected','=','ok'),
                                    ('state','=','done')
                                    ])
        workorder = []
        if not wo_search :
            workorder = []
        elif wo_search :
            wo_browse = wo_pool.browse(cr,uid,wo_search)           
            for x in wo_browse :
                workorder.append([0,0,{
                                 'id':x.id,
                                 'name':x.name,
                                 'lot_id':x.lot_id.id,                                 
                                 'chassis_no':x.chassis_no,
                                 'date':x.date,
                                 'type':x.type,
                                 'kpb_ke':x.kpb_ke,
                                 'km':x.km,
                                 'state':x.state,
                                 'kpb_collected':x.kpb_collected,   
                
                }])
                
        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']:
            wo_collect.append(x)
        print "ini daftar work order",wo_collect
        del[vals['work_order_ids']]
        
        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,[
                                    ('branch_id','=',vals['branch_id']),
                                    ('kpb_collected','=','ok'),
                                    ('state','=','done'),
                                    ('collecting_id','=',False),
        
                                    ])
        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 
                    y.write({
                           'kpb_collected':'collected',
                           'collecting_id':collecting_id,
                           })
        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 .

Avatar
Discard
Best Answer

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.
 

Avatar
Discard
Author

yes you were right , i found the answer thanks