From 2deb110a238bbd8a0a6c41f58f15dc1f693b4fe1 Mon Sep 17 00:00:00 2001 From: "Harry (OpenERP)" Date: Mon, 24 Sep 2012 12:09:51 +0530 Subject: [PATCH] [IMP] hr_attendance: refactor code bzr revid: hmo@tinyerp.com-20120924063951-ub602rou1p9wtt7p --- addons/hr_attendance/hr_attendance.py | 17 +++++++---------- .../hr_timesheet_sheet_data.xml | 2 +- 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/addons/hr_attendance/hr_attendance.py b/addons/hr_attendance/hr_attendance.py index 626fd45ba42..a2ee3650a2f 100644 --- a/addons/hr_attendance/hr_attendance.py +++ b/addons/hr_attendance/hr_attendance.py @@ -127,20 +127,17 @@ class hr_employee(osv.osv): return result def _attendance_access(self, cr, uid, ids, name, args, context=None): - res = {} - data_obj = self.pool.get('ir.model.data') - group = data_obj.get_object(cr, uid, 'base', 'group_hr_attendance') - for id in ids : - if uid in [user.id for user in group.users]: - res[id] = True - else: - res[id] = False - return res + # this function field use to hide attendance button to singin/singout from menu + group = self.pool.get('ir.model.data').get_object(cr, uid, 'base', 'group_hr_attendance') + visible = False + if uid in [user.id for user in group.users]: + visible = True + return dict([(x, visible) for x in ids]) _columns = { 'state': fields.function(_state, type='selection', selection=[('absent', 'Absent'), ('present', 'Present')], string='Attendance'), 'last_sign': fields.function(_last_sign, type='datetime', string='Last Sign'), - 'attendance_access': fields.function(_attendance_access, type='boolean', string="Access or not"), + 'attendance_access': fields.function(_attendance_access, type='boolean'), } def _action_check(self, cr, uid, emp_id, dt=False, context=None): diff --git a/addons/hr_timesheet_sheet/hr_timesheet_sheet_data.xml b/addons/hr_timesheet_sheet/hr_timesheet_sheet_data.xml index c3bab3b4ad1..87edf949972 100644 --- a/addons/hr_timesheet_sheet/hr_timesheet_sheet_data.xml +++ b/addons/hr_timesheet_sheet/hr_timesheet_sheet_data.xml @@ -20,7 +20,7 @@ My Timesheet - +