0
votes

How do you add new line to one2many?

I have tried

car_ids = fields.One2many()
for line in used_car_ids:
    value = {   'make': line.make,
                'type': line.type
            }
    self.car_ids = [(0,0,value)]

But it does not append. The car_ids will always be filled with only one used_car_ids (only the last used_car_ids)

How do I append to one2many?

2

2 Answers

3
votes

Maybe you should try the following:

car_ids = fields.One2many()

result = []
for line in used_car_ids:
    result.append((0, 0, {'make': line.make, 'type': line.type}))
self.car_ids = result

Hope that will help.

0
votes

Solved, like this.

for record in estudiante:
        participante.append(self.env['universidad.participante'].create({
            'primer_nombre_participante':record.primer_nombre,
            'primer_apellido_participante':record.primer_apellido,
            }).id)
    vals['participantes_ids'] = [(6,0,participante)]