[IMP] issue #585361: give a more explicit error message when a user tries to delete an invoice that has been validated (i.e. assigned a sequence number)
also, replace the old fashioned exceptions with the new implementation (one rock, two birds) bzr revid: abo@openerp.com-20130215171053-grkz9tkfsy2nkh3y
This commit is contained in:
parent
fe7dc3d817
commit
81037740e1
|
@ -451,11 +451,15 @@ class account_invoice(osv.osv):
|
|||
context = {}
|
||||
invoices = self.read(cr, uid, ids, ['state','internal_number'], context=context)
|
||||
unlink_ids = []
|
||||
|
||||
for t in invoices:
|
||||
if t['state'] in ('draft', 'cancel') and t['internal_number']== False:
|
||||
unlink_ids.append(t['id'])
|
||||
if t['state'] not in ('draft', 'cancel'):
|
||||
raise openerp.exceptions.Warning(_('You cannot delete an invoice which is not cancelled. You should refund it instead.'))
|
||||
elif t['internal_number'] == False:
|
||||
raise openerp.exceptions.Warning(_('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.'))
|
||||
else:
|
||||
raise osv.except_osv(_('Invalid Action!'), _('You can not delete an invoice which is not cancelled. You should refund it instead.'))
|
||||
unlink_ids.append(t['id'])
|
||||
|
||||
osv.osv.unlink(self, cr, uid, unlink_ids, context=context)
|
||||
return True
|
||||
|
||||
|
|
Loading…
Reference in New Issue