title: Odoo 10 - Overriding unlink method
body: <p>I am overriding unlink method from account.invoice to allow delete last raised invoice.</p>
  
  <p>This is my code:</p>
  
  <pre class="lang-py prettyprint-override"><code>class AccountInvoice(models.Model):
      _inherit = "account.invoice"
  
      @api.multi
      def unlink(self):
          for invoice in self:
              if invoice.state not in ('draft', 'cancel'):
                  raise UserError(('You cannot delete an invoice which is not draft or cancelled. You should refund it instead.'))
              elif invoice.move_name:
                  if invoice.journal_id.sequence_id:
                      sequence_id = invoice.journal_id.sequence_id
                      last_assigned_number = sequence_id.next_number_do_not_increase() - 1
                      last_assigned_number_text = sequence_id.get_next_char(last_assigned_number)
                      if last_assigned_number_text == invoice.move_name:
                          invoice.journal_id.sequence_id.write({'number_next': last_assigned_number})
                      else:
                          raise UserError(('You cannot delete an invoice after it has been validated (and received a number). You can set it back to "Draft" state and modify its content, then re-confirm it.'))
          return super(AccountInvoice, self).unlink()
  </code></pre>
  
  <p>So far so good,</p>
  
  <p>My specific question is on the last line, when I ran this code flows goes so no UserErrors are raised in this ROUTINE, but then it runs super(AccountInvoice, self).unlink() and it executes the old code form account_invoice.py:</p>
  
  <pre class="lang-py prettyprint-override"><code>@api.multi
  def unlink(self):
      for invoice in self:
          if invoice.state not in ('draft', 'cancel'):
              raise UserError(_('You cannot delete an invoice which is not draft or cancelled. You should refund it instead.'))
          elif invoice.move_name:
              raise UserError(_('You cannot delete an invoice after it has been validated (and received a number). You can set it back to "Draft" state and modify its content, then re-confirm it.'))
      return super(AccountInvoice, self).unlink()
  </code></pre>
  
  <p>Which raises an error, how should I rewrite this unlink method so this does not happen?</p>