title: Create new invoice by code in another model Odoo 8
body: <p>I need to call the method write of account invoice from a button. I have a form with information and i want to create a draft invoice when the button is clicked passing the values for the invoice for parameter. Thanks</p>
  
  <p>This my value :-</p>
  
  <pre><code>partner_id (cars_reservation)&gt;&gt;&gt; partner_id (account.invoice)  
  
  product_id (cars_reservation)&gt;&gt;&gt; product_id (account.invoice.line)
  
  product_price (cars_reservation)&gt;&gt;&gt; price_unit (account.invoice.line)
  
  price_total (cars_reservation)&gt;&gt;&gt; amount_total (account.invoice)
  </code></pre>
  
  <hr>
  
  <p>this my Code class :-</p>
  
  <pre><code>class cars_reservation(models.Model): 
  
     _name = 'cars.reservation'
     _rec_name = 'name_reservation'
  
  def action_draft(self, cr, uid, ids, context=None):
      return self.write(cr,uid,ids,{'state' : 'draft'})
  
  def action_done(self, cr, uid, ids, context=None):
      return self.write(cr,uid,ids,{'state' : 'finished'})
  
  def action_cancel(self, cr, uid, ids, context=None):
      return self.write(cr,uid,ids,{'state' : 'canceled'})
  
  
  name_reservation = fields.Char('number', size=64, readonly=True)
  reservation_date_time = fields.Datetime('Date')
  partner_id = fields.Many2one('res.partner', string='Partner', required=True)
  product_id = fields.Many2one('product.product', string='Product')
  product_price = fields.Integer('price')
  price_total = fields.Integer('price')
  state = fields.Selection([
      ('new', 'new'),
      ('finished', 'finished'),
      ('canceled', 'canceled')
      ], 'state', readonly=True,        
      select=True)
  
  _defaults = {
  
      'state': lambda * a:'new',
      'name_reservation': lambda self,cr,uid,context={}: self.pool.get('ir.sequence').get(cr, uid, 'reg_code'),
  
  } 
  </code></pre>