How to automatically fill a one2many field values to another one2many field in odoo
<p>I have two one2many field which is reffering to a single model, existing in different models.</p>

<p>ie,</p>

<pre><code>    class modelA(models.Model):
       _name = 'modela'

       fila = fields.One2many('main','refa')

   class moddelB(models.Model):
      _name = 'modelb'

      filb = fields.One2many('main','refb')


   class main(models.Model):
     _name = 'main'

     name = fields.Char('Name')
     date = fields.Date('Date')
     refa = fields.Many2one('modela')
     refb = fields.Many2one('modelb')
</code></pre>

<p>I will create records in <strong>modela</strong>. In this model there is a button is there. On clicking on that button i need to copy all values of fila field to filb field of  <strong>modelb</strong> . How can i do that.</p>

<p>You need to use <a href="http://odoo-development.readthedocs.io/en/latest/dev/py/x2many.html#x2many-values-filling" rel="nofollow">One2manu values filling</a></p>

<p><strong>XML code</strong>  </p>

<pre><code>&lt;button name="copy2b" type="object" string="COPY"/&gt;  
</code></pre>

<p><strong>Python code</strong>:  </p>

<pre><code>@api.multi
def copy2b(self):
    for record in self:
        filb_values = [(0, 0, {'name': line.name, 'date': line.date}) for line in record.fila]
        vals = {'filb': filb_values}
        # Just pass these values to `create` or `write` method to save them on `modelb`
</code></pre>

python odoo-8