Assign a value to a One2Many field

Hello,

how to change the value of a One2Many field in an on_change function.
otherwise how to do: fields_one_2_many = new_value ?

Thanks in advance !

Yes, you should assign a list of instances of the records you want to change.
Note that you can update existing records if they are available by just changing some fields of it. Or you can also remove or add new records by adding/removing them from the list of instances.

Of you’ve done all the changes you just need to assign the list to the self with:

self.one2many_field = list_of_instances

Hope it helps

I have already tried this solution, but it did not work. No changes were made.

Please share your code because it should work.