As code below , I could add record to the one2many field 'f_12m' when the other field 'onte' was changed . But the problem is that when I change the 'note' value again , it delete all the records of 'f_12m' field , then add a new record . How can i keep the old records and add new one , without saving the whold model ?
f_12m = fields.One2many( 'x_app.other_model', 'oid', string= 'FieldName' )
@api.onchange( 'note' )
def _onchange_note( self ) :
dic_value = {}
list_f_12m = []
list_f_12m.append( ( 0 , 0 , {'note':self.note} ) )
dic_value.update( f_12m = list_f_12m )
return {'value': dic_value }
Please try below code
Hope this helps!