diff --git a/addons/hr_attendance/__init__.py b/addons/hr_attendance/__init__.py index dadb043e016..feb32e22792 100644 --- a/addons/hr_attendance/__init__.py +++ b/addons/hr_attendance/__init__.py @@ -22,5 +22,6 @@ import hr_attendance import wizard import report +import res_config # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/hr_attendance/__openerp__.py b/addons/hr_attendance/__openerp__.py index c125174fed1..29ee6869241 100644 --- a/addons/hr_attendance/__openerp__.py +++ b/addons/hr_attendance/__openerp__.py @@ -42,6 +42,7 @@ actions(Sign in/Sign out) performed by them. 'wizard/hr_attendance_bymonth_view.xml', 'wizard/hr_attendance_byweek_view.xml', 'wizard/hr_attendance_error_view.xml', + 'res_config_view.xml', ], 'demo': ['hr_attendance_demo.xml'], 'test': [ diff --git a/addons/hr_attendance/hr_attendance.py b/addons/hr_attendance/hr_attendance.py index 8fdd2928fe6..3a704e8f466 100644 --- a/addons/hr_attendance/hr_attendance.py +++ b/addons/hr_attendance/hr_attendance.py @@ -126,9 +126,20 @@ class hr_employee(osv.osv): result[id] = res[0] 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,'hr_attendance', 'hr_attendace_group') + if uid in [user.id for user in group.user]: + res[ids] = True + else: + res[ids] = False + return res + _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"), } def _action_check(self, cr, uid, emp_id, dt=False, context=None): diff --git a/addons/hr_attendance/res_config.py b/addons/hr_attendance/res_config.py new file mode 100644 index 00000000000..02eeb4c0d21 --- /dev/null +++ b/addons/hr_attendance/res_config.py @@ -0,0 +1,33 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# OpenERP, Open Source Business Applications +# Copyright (C) 2004-2012 OpenERP S.A. (). +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# +############################################################################## + +from osv import fields, osv + +class hr_attendance_config_settings(osv.osv_memory): + _inherit = 'hr.config.settings' + + _columns = { + 'group_hr_attendance': fields.boolean('Allow to show Attendance details.', + implied_group='base.group_hr_attendance', + help="To allow to show Attendance details."), + } + +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/hr_attendance/res_config_view.xml b/addons/hr_attendance/res_config_view.xml new file mode 100644 index 00000000000..5ab8ea82af9 --- /dev/null +++ b/addons/hr_attendance/res_config_view.xml @@ -0,0 +1,20 @@ + + + + + hr.config.settings.inherit + hr.config.settings + + + + +
+ +
+
+
+
+
+
+
diff --git a/addons/hr_attendance/static/src/js/attendance.js b/addons/hr_attendance/static/src/js/attendance.js index 1b5e271b4ba..0068b495628 100644 --- a/addons/hr_attendance/static/src/js/attendance.js +++ b/addons/hr_attendance/static/src/js/attendance.js @@ -57,9 +57,12 @@ openerp.hr_attendance = function (instance) { var employee = new instance.web.DataSetSearch(self, 'hr.employee', self.session.user_context, [ ['user_id', '=', self.session.uid] ]); - return employee.read_slice(['id', 'name', 'state', 'last_sign']).pipe(function (res) { - if (_.isEmpty(res)) + return employee.read_slice(['id', 'name', 'state', 'last_sign', 'attendance_access']).pipe(function (res) { + if (_.isEmpty(res) ) return; + if (res['attendance_access'] == false){ + return; + } self.$el.show(); self.employee = res[0]; self.last_sign = instance.web.str_to_datetime(self.employee.last_sign);