From 86597698aa994e439adbb2af281cd3fdad58165a Mon Sep 17 00:00:00 2001 From: husen daudi Date: Tue, 7 Apr 2009 17:45:46 +0530 Subject: [PATCH] bugfixed for delete invoices Bug#356854 lp bug: https://launchpad.net/bugs/356854 fixed bzr revid: hda@hda-20090407121546-91otm4hgqpzz4dv8 --- addons/account/invoice.py | 33 +++++++++------------------------ 1 file changed, 9 insertions(+), 24 deletions(-) diff --git a/addons/account/invoice.py b/addons/account/invoice.py index 0bd58afe90a..e48863315a3 100644 --- a/addons/account/invoice.py +++ b/addons/account/invoice.py @@ -290,30 +290,15 @@ class account_invoice(osv.osv): } def unlink(self, cr, uid, ids, context=None): - for inv in self.browse(cr, uid, ids, context): - print inv.name, inv.amount_total - for line in inv.invoice_line: - print line.price_subtotal -# invoices = self.read(cr, uid, ids, ['state']) -# unlink_ids = [] -# for t in invoices: -# if t['state'] in ('draft', 'cancel'): -# unlink_ids.append(t['id']) -# else: -# raise osv.except_osv(_('Invalid action !'), _('Cannot delete invoice(s) that are already opened or paid !')) -# osv.osv.unlink(self, cr, uid, unlink_ids, context=context) -# return True - - #def unlink(self, cr, uid, ids, context=None): - # invoices = self.read(cr, uid, ids, ['state']) - # unlink_ids = [] - # for t in invoices: - # if t['state'] in ('draft', 'cancel'): - # unlink_ids.append(t['id']) - # else: - # raise osv.except_osv(_('Invalid action !'), _('Cannot delete invoice(s) that are already opened or paid !')) - # osv.osv.unlink(self, cr, uid, unlink_ids, context=context) - # return True + invoices = self.read(cr, uid, ids, ['state']) + unlink_ids = [] + for t in invoices: + if t['state'] in ('draft', 'cancel'): + unlink_ids.append(t['id']) + else: + raise osv.except_osv(_('Invalid action !'), _('Cannot delete invoice(s) that are already opened or paid !')) + osv.osv.unlink(self, cr, uid, unlink_ids, context=context) + return True # def get_invoice_address(self, cr, uid, ids): # res = self.pool.get('res.partner').address_get(cr, uid, [part], ['invoice'])