title: Set default value while creating record from one2many field - odoo
body: <p>I want to set default value for multiple fields while creating records from one2many field, in that default value will be taken from the parent model.</p>
  
  <p><strong>Odoo Model Structure</strong></p>
  
  <pre><code>class purchase_order(models.Model):
      _inherit='purchase.order'
  
      cash_forecast_ids = fields.One2many(comodel_name='cash.forecast', inverse_name='purchase_order_id', string='Payment Schedules')
  
  
  class cash_forecast(models.Model):
      _name='cash.forecast'
  
      purchase_order_id = fields.Many2one(comodel_name='purchase.order', string='PO', select=True, copy=False)
      foreign_currency_amount = fields.Float("Foreign Currency Amount", copy=False)
      currency_id = fields.Many2one(comodel_name="res.currency", string="Currency", copy=False)
      company_id = fields.Many2one(comodel_name='res.company', string='Company')
  </code></pre>
  
  <blockquote>
    <p><strong>Problem :</strong>
    Now what I want to do is, I want to set currency and company from the
    purchase order while the cash forecast record will be created from the
    PO form view, but I don't know how to do it.</p>
    
    <p><strong>NOTE</strong> : I am not able take currency or company field related or
    functional because there are few other situations for which company and
    currency should be entered manually and in that no PO reference will be set.</p>
  </blockquote>
  
  <p><strong>PO Form View</strong> </p>
  
  <pre><code>&lt;page string="Deliveries &amp;amp; Invoices" position="after"&gt;
      &lt;page string="Payment Scedule"&gt;
          &lt;field name="cash_forecast_ids" attrs="{'readonly' : [('state','in',['done','cancel'])]}"&gt;
              &lt;tree string="Payment Scedule" editable="bottom"&gt;
                  &lt;field name="name"/&gt;
                  &lt;field name="cash_forecast_type_id" required="1" domain="[('add_to_po_payment_schedule','=',True)]" /&gt;
                  &lt;field name="note" /&gt;
                  &lt;field name="forecast_date" /&gt;
                  &lt;field name="period_id" required="1" /&gt;
                  &lt;field name="foreign_currency_amount" required="1" /&gt;
                  &lt;field name="currency_id" required="1" /&gt;
                  &lt;field name="purchase_order_id" invisible="1"/&gt;
                  &lt;field name="company_id" required="1" /&gt; 
              &lt;/tree&gt;
          &lt;/field&gt;
      &lt;/page&gt;
  &lt;/page&gt;
  </code></pre>
  
  <p>Can any one suggest me, what should I do in that case ?</p>