[IMP]add config file in hr_attendance
bzr revid: pna@tinyerp.com-20120921134405-0q3mwq6dsp2fw4yu
This commit is contained in:
parent
713dff9dba
commit
008d5d35d7
|
@ -22,5 +22,6 @@
|
|||
import hr_attendance
|
||||
import wizard
|
||||
import report
|
||||
import res_config
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
|
|
|
@ -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': [
|
||||
|
|
|
@ -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):
|
||||
|
|
|
@ -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:
|
|
@ -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>
|
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue