From a9f0d92036fc517c92045f7159bab6c173defa17 Mon Sep 17 00:00:00 2001 From: "aag (OpenERP)" Date: Tue, 15 Mar 2011 17:00:55 +0530 Subject: [PATCH] [IMP] Account: Now we can restrict the deletion of account.invoice if it has a number bzr revid: aag@tinyerp.co.in-20110315113055-wjskqh82rafug9zg --- addons/account/invoice.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/addons/account/invoice.py b/addons/account/invoice.py index 5f1beca0d32..27a45b90f27 100644 --- a/addons/account/invoice.py +++ b/addons/account/invoice.py @@ -362,13 +362,13 @@ class account_invoice(osv.osv): def unlink(self, cr, uid, ids, context=None): if context is None: context = {} - invoices = self.read(cr, uid, ids, ['state'], context=context) + invoices = self.read(cr, uid, ids, ['state','internal_number'], context=context) unlink_ids = [] for t in invoices: - if t['state'] in ('draft', 'cancel'): + if t['state'] in ('draft', 'cancel') and t['internal_number']== False: unlink_ids.append(t['id']) else: - raise osv.except_osv(_('Invalid action !'), _('Cannot delete invoice(s) that are already opened or paid !')) + raise osv.except_osv(_('Invalid action !'), _('Cannot delete invoice(s) that are already opened(or been in opened state ever) or paid!')) osv.osv.unlink(self, cr, uid, unlink_ids, context=context) return True