I having a form with one2many field, in that one2many it having 10 line items, in the form I update some sequence number to that one2many, if I change the value in 5th line item that sequences need to update 6th to 10th line item how to do that in ODOO.
@Axel Mendoza, In this image I change the value 6 as 15 then next records are need to change automatically. How to do that.
class xform(osv.osv):_name = 'xform'_columns = {'name': fields.char('Name', size=64),'xstate': fields.text('XState'),'xmany_ids': fields.one2many('xmany', 'xform_id', string='Xmany'),}_defaults = {'xstate': '{}'}def onchange_many_lines(self, cr, uid, ids, xmany_ids, xstate):#to save the state of modified fields to latter could detect new changesxstate = json.loads(xstate)lines = []xlast = False#for identify non saved linesindex = 0for xline in xmany_ids:if not xlast:#detecting the actual modified lineif xline[0] in (0,1) and xline[2].get('xvalue', False):if (xline[0] == 0 and xstate.get('new-%s'%index,False) != xline[2].get('xvalue')) or \(xline[0] == 1 and xstate.get(xline[1],False) != xline[2].get('xvalue')):xlast = xline[2].get('xvalue')if xline[0] == 0:xstate['new-%s'%index] = xline[2]if xline[0] == 1:xstate[xline[1]] = xline[2]lines.append(xline)print lines,"$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"else:#not a deleted lineif xline[0] != 2:xlast+=1else:lines.append(xline)#new line not saved yetif xline[0] == 0:data = {'xvalue': xlast}if xline[2].get('name', False):data.update({'name': xline[2]['name']})lines.append((0, 0, data))xstate['new-%s'%index] = xlast#existing lines, 1: modified line and 4: linked line to an existing recordelif xline[0] in (1,4):data = {'xvalue': xlast}if xline[0] == 1 and xline[2].get('name', False):data.update({'name': xline[2]['name']})lines.append((1, xline[1], data))xstate[xline[1]] = xlastindex+=1if not xlast:print xlast,"PPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPP"return {}print json.dumps(xlast),"$$$$$$$$$$$$$$$$$$$$$$$$$$$"return {'values': {'xstate': json.dumps(xlast), 'xmany_ids': lines}}xform()class xmany(osv.osv):_name = 'xmany'_columns = {'name': fields.char('Name', size=64),'xvalue': fields.integer('XValue'),'xform_id': fields.many2one('xform', string='XForm'),}xmany()
1 | a |
2 | b |
3 | c |
4 | d |
5 | e |
15 | f |
16 | g |
17 | h |
18 | i |
19 | j |
Describe more what you need, it can be done but you need to be more specific