Odoo Help


Can't save one2many record after onchange odooV8

Ajeng Shilvie
on 1/16/15, 3:18 AM 861 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)


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/16/15, 3:18 AM
Seen: 861 times
Last updated: 3/16/15, 8:10 AM