Odoo Help


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.


Can't save one2many record after onchange odooV8

Ajeng Shilvie
on 1/16/15, 3:18 AM 592 views

I want to make onchange field in many2one field , to onchange one2many field in different object.. Once i select many2one field it return several record. But when i hit button save it disapper .. how to resolve this ? thanks in advance

class wtc_collecting_kpb(osv.osv):
    _name = "wtc.collecting.kpb"

    _columns = {
        'name': fields.char('Collecting KPB', size=64, readonly=True),
        'branch_id':fields.many2one('wtc.branch','Branch',required=True, change_default=1), 
        'division':fields.selection([('Sparepart','Sparepart')],'Division', change_default=True,select=True,required=True),
        'work_order_ids': fields.one2many('wtc.work.order','collecting_id',string="Table Collecting KPB"),

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

        default = {

        if not branch_id:
            return 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 :
                workorder.append([0, False, {
        default['value'].update({'work_order_ids': workorder,})
        return default    
    def create(self,cr,uid,vals,context=None):
        wo_pool = self.pool.get('wtc.work.order')
        wo_search = wo_pool.search(cr,uid,[
        wo_browse = wo_pool.browse(cr,uid,wo_search)
        y = 0
        for x in wo_browse :
            print "jdfdjnfjdnfdjfjkdnf       ",x
            y += 1
            print "tyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy",y
            for vals['work_order_ids'] in x:
        return super(wtc_collecting_kpb, self).create(cr, uid, vals, context=context)


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)


Asked: 1/16/15, 3:18 AM
Seen: 592 times
Last updated: 3/16/15, 8:10 AM