答案 0 :(得分:0)
您可以在One2many字段中添加“ onchange”功能
@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