title: Odoo 8 : how to link a Many2one field automatically with the parent model?
body: <p>I created a new model 'sale.order.category' in order to group Sale Order Lines in specific subcategories (allowing to display subtotals, etc.)</p>
  
  <pre><code>class SaleOrderCategory(models.Model):
      _name = 'sale.order.category'
      name = fields.Char('Name', required=True)
      line_ids = fields.One2many('sale.order.line', 'category_id', 'Order Lines in this category')
      order_id = fields.Many2one('sale.order', 'Order', required=True, readonly=True)
  
  class SaleOrder(models.Model):
      _name = 'sale.order'
      _inherit = 'sale.order'
      order_category_ids = fields.One2many('sale.order.category', 'order_id', 'Categories in this order', readonly=True, copy=True)
  </code></pre>
  
  <p>Just for info, here is my Order lines tree view modification to add the Category column :</p>
  
  <pre><code>&lt;!-- adds a category column in the order lines list --&gt;
  &lt;xpath expr="//field[@name='order_line']/tree/field[@name='name']" position="after"&gt;
      &lt;field name="category_id"/&gt;
  &lt;/xpath&gt;
  </code></pre>
  
  <p>My question is : how can I automatically populate the order_id field with the current Sales Order ID when I create a new Category through the Order Lines Tree (inside a Sales Order) ?</p>
  
  <p>Many thanks,
  Max</p>