[IMP]add config file in hr_attendance
authorPinakin Nayi (OpenERP) <pna@tinyerp.com>
Fri, 21 Sep 2012 13:44:05 +0000 (19:14 +0530)
committerPinakin Nayi (OpenERP) <pna@tinyerp.com>
Fri, 21 Sep 2012 13:44:05 +0000 (19:14 +0530)
bzr revid: pna@tinyerp.com-20120921134405-0q3mwq6dsp2fw4yu

addons/hr_attendance/__init__.py
addons/hr_attendance/__openerp__.py
addons/hr_attendance/hr_attendance.py
addons/hr_attendance/res_config.py [new file with mode: 0644]
addons/hr_attendance/res_config_view.xml [new file with mode: 0644]
addons/hr_attendance/static/src/js/attendance.js

index dadb043..feb32e2 100644 (file)
@@ -22,5 +22,6 @@
 import hr_attendance
 import wizard
 import report
+import res_config
 
 # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
index c125174..29ee686 100644 (file)
@@ -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': [
index 8fdd292..3a704e8 100644 (file)
@@ -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 (file)
index 0000000..02eeb4c
--- /dev/null
@@ -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 (file)
index 0000000..5ab8ea8
--- /dev/null
@@ -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>
index 1b5e271..0068b49 100644 (file)
@@ -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);