From d4f970ff9ccb21d6e31982e70f8d41f9075b6cbd Mon Sep 17 00:00:00 2001 From: "Khushboo Bhatt (Open ERP)" Date: Tue, 23 Oct 2012 18:09:10 +0530 Subject: [PATCH] [IMP]hr_expense:delete only those expense which are in draft states bzr revid: kbh@tinyerp.com-20121023123910-v1sd0wtgis9cn0w6 --- addons/hr_expense/hr_expense.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/addons/hr_expense/hr_expense.py b/addons/hr_expense/hr_expense.py index ee79e03fa77..06852e08e96 100644 --- a/addons/hr_expense/hr_expense.py +++ b/addons/hr_expense/hr_expense.py @@ -100,6 +100,12 @@ class hr_expense_expense(osv.osv): 'currency_id': _get_currency, } + def unlink(self, cr, uid, ids, context=None): + for rec in self.browse(cr, uid, ids, context=context): + if rec.state != 'draft': + raise osv.except_osv(_('Warning!'),_('You cannot delete an expense which is in %s state!')%(rec.state)) + return super(hr_expense_expense, self).unlink(cr, uid, ids, context) + def onchange_currency_id(self, cr, uid, ids, currency_id=False, company_id=False, context=None): res = {'value': {'journal_id': False}} journal_ids = self.pool.get('account.journal').search(cr, uid, [('type','=','purchase'), ('currency','=',currency_id), ('company_id', '=', company_id)], context=context)