How to override only the unlink method of account_invoice class?
I'm trying to override the unlink method in the class account_invoice. To be able to erase invoice when I make tests.
I want the shortest possible code. What I do wrong?
from openerp import models, fields, api
_inherit = ['account.invoice']
_inherit = ['unlink']
for invoice in self:
if invoice.state not in ('draft', 'cancel'):
raise Warning(_('You cannot delete an invoice which is not draft or cancelled. You should refund it instead.'))
return super(account_invoice, self).unlink()