title: auto increment - internal reference odoo9
body: <p>I want to change the type of the field 'ref' (Internal Reference) to be auto incremented (for example every time I create a new contact my Internal Reference should increase by 1). So first contact should have Internal Reference 1, the second 2, the third 3 and so on...</p>
  
  <p>There are no errors but still the reference field is empty. Have I missed some additional code? Can someone help me?</p>
  
  <pre><code>@api.model
  def create(self, vals):
      if vals.get('ref', 'New') == 'New':
          vals['ref'] = self.env['ir.sequence'].next_by_code(
              'res.debt') or 'New'
      return super(Partner, self).create(vals)
  </code></pre>
  
  <p>And the xml file:</p>
  
  <pre><code>      &lt;record id="your_sequence_id" model="ir.sequence"&gt;
            &lt;field name="name"&gt;Reference&lt;/field&gt;
            &lt;field name="padding"&gt;3&lt;/field&gt;
            &lt;field name="code"&gt;res.debt&lt;/field&gt;
        &lt;/record&gt;
  </code></pre>
  
  <p><img src="https://i.stack.imgur.com/EMIn7.png" alt="Example of current result"></p>