Hello all,
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
class account_invoice(models.Model):
_inherit = ['account.invoice']
@api.multi
def unlink(self):
_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()
thanks all