From 5cc4b243b683f7ecf69b1ae2e18247d82950e50b Mon Sep 17 00:00:00 2001 From: mtr Date: Tue, 28 Jun 2011 17:16:33 +0530 Subject: [PATCH] [FIX] hr_holidays:-Exception raised on confirmation of leave request is now translated in user's lang. lp bug: https://launchpad.net/bugs/798739 fixed bzr revid: mtr@mtr-20110628114633-78h4k4q3d8jectjo --- addons/hr_holidays/hr_holidays.py | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/addons/hr_holidays/hr_holidays.py b/addons/hr_holidays/hr_holidays.py index 7074fd5cecc..4c000aab968 100644 --- a/addons/hr_holidays/hr_holidays.py +++ b/addons/hr_holidays/hr_holidays.py @@ -224,14 +224,20 @@ class hr_holidays(osv.osv): return True def holidays_validate(self, cr, uid, ids, *args): - self.check_holidays(cr, uid, ids) + context = {} + lang = self.pool.get('res.users').browse(cr, uid, uid).context_lang + context.update({'lang': lang}) + self.check_holidays(cr, uid, ids, context=context) obj_emp = self.pool.get('hr.employee') ids2 = obj_emp.search(cr, uid, [('user_id', '=', uid)]) manager = ids2 and ids2[0] or False return self.write(cr, uid, ids, {'state':'validate1', 'manager_id': manager}) def holidays_validate2(self, cr, uid, ids, *args): - self.check_holidays(cr, uid, ids) + context = {} + lang = self.pool.get('res.users').browse(cr, uid, uid).context_lang + context.update({'lang': lang}) + self.check_holidays(cr, uid, ids, context=context) obj_emp = self.pool.get('hr.employee') ids2 = obj_emp.search(cr, uid, [('user_id', '=', uid)]) manager = ids2 and ids2[0] or False @@ -277,7 +283,10 @@ class hr_holidays(osv.osv): return True def holidays_confirm(self, cr, uid, ids, *args): - self.check_holidays(cr, uid, ids) + context = {} + lang = self.pool.get('res.users').browse(cr, uid, uid).context_lang + context.update({'lang': lang}) + self.check_holidays(cr, uid, ids, context=context) return self.write(cr, uid, ids, {'state':'confirm'}) def holidays_refuse(self, cr, uid, ids, *args): @@ -302,8 +311,10 @@ class hr_holidays(osv.osv): return True - def check_holidays(self, cr, uid, ids): + def check_holidays(self, cr, uid, ids, context=None): holi_status_obj = self.pool.get('hr.holidays.status') + if context is None: + context = {} for record in self.browse(cr, uid, ids): if record.holiday_type == 'employee' and record.type == 'remove': if record.employee_id and not record.holiday_status_id.limit: