[IMP]hr_expense:delete only those expense which are in draft states

bzr revid: kbh@tinyerp.com-20121023123910-v1sd0wtgis9cn0w6
This commit is contained in:
Khushboo Bhatt (Open ERP) 2012-10-23 18:09:10 +05:30
parent 3bde64f49c
commit d4f970ff9c
1 changed files with 6 additions and 0 deletions

View File

@ -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)