title: To get default values in one2many odoo 12
body: <p>actually i got 2 models,A and B ,connection same as sale.order and sale.order.line ,that connecting line here is medicine_line it is a one2many field.so when adding a specialist_name in model A,&quot;each line&quot; in the model B's(Notebook) specialist_name wants to get by default .</p>
  <p>I have tried below code but getting the name only on the first line of the notebook:</p>
  <p>*<strong>.py</strong></p>
  <p>medicine_line = One2many field</p>
  <pre><code>@api.onchange('specialist_name')
  def _onchange_specialist_name(self):
      for record in self:
          for each in record.medicine_line:
              if record.specialist_name:
                  lines = [(5, 0, 0)]
                  for line in self.specialist_name:
                      val = {
                          'specialist_name': line.id,
                      }
                      lines.append((0, 0, val))
                  record.each = lines
  </code></pre>