diff options
| author | Pinakin Nayi (OpenERP) <pna@tinyerp.com> | 2012-09-21 19:14:05 +0530 |
|---|---|---|
| committer | Pinakin Nayi (OpenERP) <pna@tinyerp.com> | 2012-09-21 19:14:05 +0530 |
| commit | 008d5d35d7b944c54bc7e8f16bbe8c5a2966f2be (patch) | |
| tree | 9ff7184740ba64b99ca0ecf4d12ffc9ea609d7a6 | |
| parent | 713dff9dbaf562e8955b94b45b0a1681199ec7fd (diff) | |
[IMP]add config file in hr_attendance
bzr revid: pna@tinyerp.com-20120921134405-0q3mwq6dsp2fw4yu
| -rw-r--r-- | addons/hr_attendance/__init__.py | 1 | ||||
| -rw-r--r-- | addons/hr_attendance/__openerp__.py | 1 | ||||
| -rw-r--r-- | addons/hr_attendance/hr_attendance.py | 11 | ||||
| -rw-r--r-- | addons/hr_attendance/res_config.py | 33 | ||||
| -rw-r--r-- | addons/hr_attendance/res_config_view.xml | 20 | ||||
| -rw-r--r-- | addons/hr_attendance/static/src/js/attendance.js | 7 |
6 files changed, 71 insertions, 2 deletions
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. (<http://openerp.com>). +# +# 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 <http://www.gnu.org/licenses/>. +# +############################################################################## + +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 @@ +<?xml version="1.0" encoding="utf-8"?> +<openerp> + <data noupdate="1"> + <record id="hr_attendace_group" model="ir.ui.view"> + <field name="name">hr.config.settings.inherit</field> + <field name="model">hr.config.settings</field> + <field name="inherit_id" ref="hr.view_human_resources_configuration"/> + <field name="arch" type="xml"> + <data> + <xpath expr="//div[@name='hr_timesheet']" position="after"> + <div> + <field name="group_hr_attendance" class="oe_inline"/> + <label for="group_hr_attendance"/> + </div> + </xpath> + </data> + </field> + </record> + </data> +</openerp> 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); |
