1
votes

Please I create a wizard like this

enter image description here

Now I need when I click Enregistrer Button to create those fields in the tree view on the bottom

for this example, I have quantity equal 12 so I need 12 lines to be created on the tree view with the values on the wizard view

1
You could to add "onchange" function in your One2many field.Carlos Herrera

1 Answers

0
votes

You could to add "onchange" function in your One2many field

@api.onchange('my_one2many_field')
def onchange_field(self):
    if self.my_one2many_field:
        current_record = self.my_one2many_field[0]
        number_of_lines = current_record.quantity

        all_records = []
        for i in range(0, number_of_lines):
            values = dict()
            values['field_1'] = current_record.field_1
            values['field_n'] = current_record.field_n
            all_records.append((0, 0, values))

        self.my_one2many_field = all_records