Antony Lesuisse (OpenERP) has proposed merging 
lp:~openerp-dev/openobject-addons/trunk-hr-attendance into lp:openobject-addons.

Requested reviews:
  OpenERP Core Team (openerp)

For more details, see:
https://code.launchpad.net/~openerp-dev/openobject-addons/trunk-hr-attendance/+merge/111514
-- 
https://code.launchpad.net/~openerp-dev/openobject-addons/trunk-hr-attendance/+merge/111514
Your team OpenERP R&D Team is subscribed to branch 
lp:~openerp-dev/openobject-addons/trunk-hr-attendance.
=== modified file 'hr_attendance/__openerp__.py'
--- hr_attendance/__openerp__.py	2012-05-18 05:26:05 +0000
+++ hr_attendance/__openerp__.py	2012-06-21 23:10:49 +0000
@@ -43,7 +43,6 @@
         'wizard/hr_attendance_bymonth_view.xml',
         'wizard/hr_attendance_byweek_view.xml',
         'wizard/hr_attendance_error_view.xml',
-        'wizard/hr_attendance_sign_in_out_view.xml',
     ],
     'demo_xml': ['hr_attendance_demo.xml'],
     'test': [
@@ -53,5 +52,10 @@
     'installable': True,
     'auto_install': False,
     'certificate': '0063495605613',
+    
+    #web
+    "js": ["static/src/js/attendance.js"],
+    'qweb' : ["static/src/xml/attendance.xml"],
+    'css' : ["static/src/css/slider.css"],
 }
 # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

=== modified file 'hr_attendance/hr_attendance.py'
--- hr_attendance/hr_attendance.py	2012-01-31 13:36:57 +0000
+++ hr_attendance/hr_attendance.py	2012-06-21 23:10:49 +0000
@@ -122,30 +122,25 @@
         res = cr.fetchone()
         return not (res and (res[0]>=(dt or time.strftime('%Y-%m-%d %H:%M:%S'))))
 
-    def attendance_action_change(self, cr, uid, ids, type='action', context=None, dt=False, *args):
-        obj_attendance = self.pool.get('hr.attendance')
-        id = False
-        warning_sign = 'sign'
-        res = {}
-
-        #Special case when button calls this method: type=context
-        if isinstance(type, dict):
-            type = type.get('type','action')
-        if type == 'sign_in':
-            warning_sign = "Sign In"
-        elif type == 'sign_out':
-            warning_sign = "Sign Out"
-        for emp in self.read(cr, uid, ids, ['id'], context=context):
-            if not self._action_check(cr, uid, emp['id'], dt, context):
-                raise osv.except_osv(_('Warning'), _('You tried to %s with a date anterior to another event !\nTry to contact the administrator to correct attendances.')%(warning_sign,))
-
-            res = {'action': type, 'employee_id': emp['id']}
-            if dt:
-                res['name'] = dt
-        id = obj_attendance.create(cr, uid, res, context=context)
-
-        if type != 'action':
-            return id
+    def attendance_action_change(self, cr, uid, ids, context=None):
+        if context is None:
+            context = {}
+        action_date = context.get('action_date', False)
+        action = context.get('action', False)
+        hr_attendance = self.pool.get('hr.attendance')
+        warning_sign = {'sign_in': _('Sign In'), 'sign_out': _('Sign Out')}
+        for employee in self.browse(cr, uid, ids, context=context):
+            if not action:
+                if employee.state == 'present': action = 'sign_out'
+                if employee.state == 'absent': action = 'sign_in'
+
+            if not self._action_check(cr, uid, employee.id, action_date, context):
+                raise osv.except_osv(_('Warning'), _('You tried to %s with a date anterior to another event !\nTry to contact the HR Manager to correct attendances.')%(warning_sign[action],))
+
+            vals = {'action': action, 'employee_id': employee.id}
+            if action_date:
+                vals['name'] = action_date
+            hr_attendance.create(cr, uid, vals, context=context)
         return True
 
 hr_employee()

=== modified file 'hr_attendance/hr_attendance_view.xml'
--- hr_attendance/hr_attendance_view.xml	2012-06-18 08:55:32 +0000
+++ hr_attendance/hr_attendance_view.xml	2012-06-21 23:10:49 +0000
@@ -56,7 +56,7 @@
                 <search string="Hr Attendance Search">
                     <filter icon="terp-stock_align_left_24" string="My Attendance" domain="[('employee_id.user_id.id', '=', uid)]" />
                     <separator orientation="vertical"/>
-                    <filter icon="terp-go-today" string="Today" name="today" domain="[('name','&gt;=',current_date),('name','&lt;=',current_date)]" />
+                    <filter icon="terp-go-today" string="Today" name="today" domain="[('name','&gt;=',time.strftime('%%Y-%%m-%%d')),('name','&lt;=',time.strftime('%%Y-%%m-%%d'))]" />
                     <separator orientation="vertical"/>
                     <field name="employee_id"/>
                     <field name="name"/>
@@ -136,8 +136,8 @@
                 <field name="coach_id" position="after">
                     <group colspan="2">
                         <field name="state"/>
-                        <button name="attendance_action_change" states="present" string="Sign Out" type="object" icon="gtk-go-forward" context="{'type':'sign_out'}" groups="base.group_hr_user"/>
-                        <button name="attendance_action_change" states="absent" string="Sign In" type="object" icon="gtk-go-back" context="{'type':'sign_in'}" groups="base.group_hr_user"/>
+                        <button name="attendance_action_change" states="present" type="object" string="Sign Out"  groups="base.group_hr_manager"/>
+                        <button name="attendance_action_change" states="absent" type="object" string="Sign In" groups="base.group_hr_manager"/>
                     </group>
                 </field>
             </field>
@@ -145,3 +145,5 @@
 
     </data>
 </openerp>
+
+

=== added directory 'hr_attendance/static'
=== added directory 'hr_attendance/static/src'
=== added directory 'hr_attendance/static/src/css'
=== added file 'hr_attendance/static/src/css/slider.css'
--- hr_attendance/static/src/css/slider.css	1970-01-01 00:00:00 +0000
+++ hr_attendance/static/src/css/slider.css	2012-06-21 23:10:49 +0000
@@ -0,0 +1,32 @@
+.oe_attendance_status{
+    height:14px;
+    width:100px;
+    background-color:white;
+    padding: 5px 10px 7px;
+    margin:3px;
+    -webkit-border-radius:4px;
+}
+.oe_attendance_present{
+    float:left;
+    text-shadow: grey 0px 1px 0px;
+    color:green;
+}
+.oe_attendance_absent{
+    float:right;
+    text-shadow: grey 0px 1px 0px;
+    color:red;
+}
+.oe_attendance_slider{
+    cursor:pointer;
+    width: 60px;
+    background-color: gray;
+    position: relative;
+    top: -4px;
+    left: -8px;
+    height: 24px;
+    -webkit-border-radius:4px;
+}
+.oe_attendance_text{
+    visibility:hidden;
+}
+

=== added directory 'hr_attendance/static/src/img'
=== added file 'hr_attendance/static/src/img/emp-absent.png'
Binary files hr_attendance/static/src/img/emp-absent.png	1970-01-01 00:00:00 +0000 and hr_attendance/static/src/img/emp-absent.png	2012-06-21 23:10:49 +0000 differ
=== added file 'hr_attendance/static/src/img/emp-present.png'
Binary files hr_attendance/static/src/img/emp-present.png	1970-01-01 00:00:00 +0000 and hr_attendance/static/src/img/emp-present.png	2012-06-21 23:10:49 +0000 differ
=== added directory 'hr_attendance/static/src/js'
=== added file 'hr_attendance/static/src/js/attendance.js'
--- hr_attendance/static/src/js/attendance.js	1970-01-01 00:00:00 +0000
+++ hr_attendance/static/src/js/attendance.js	2012-06-21 23:10:49 +0000
@@ -0,0 +1,113 @@
+openerp.hr_attendance = function(instance) {
+    var QWeb = instance.web.qweb;
+    _t = instance.web._t;
+    
+    instance.web.currentform = false;
+    instance.web.currentlist = false;
+    instance.web.attendanceslider = false;
+    
+    instance.hr_attendance.AttendanceSlider = instance.web.Widget.extend({
+        template: 'AttendanceSlider',
+        init: function(parent){
+            this.titles = {'present' :_t("Present"),
+                             'absent' :_t("Absent")          
+                            }
+            this._super(parent);
+            this.session = parent.session;
+            this.parent_element = parent.$element ;            
+        },
+        renderElement: function(){
+            this.$element = $(QWeb.render(this.template,this.titles));            
+            this.parent_element.prepend(this.$element);
+            this.$oe_attendance_slider = this.$element.find(".oe_attendance_slider");
+            this.$oe_attendance_slider.click(this.do_update_attendance);
+        },
+        do_update_attendance: function() {
+            var self = this;
+            if(!self.employee)return;
+            hr_employee = new instance.web.DataSet(self, 'hr.employee');
+            hr_employee.call('attendance_action_change', [[self.employee.id]]).done(function(result){
+                if (!result) return;
+                if(self.employee.state == 'present')
+                    self.employee.state = 'absent';
+                else
+                    self.employee.state = 'present';
+                self.do_slide(self.employee.state);
+                if(instance.web.currentlist){
+                    instance.web.currentlist.reload();
+                }
+                if(instance.web.currentform){
+                    //tofix: it should be in hr_timesheet_sheet module
+                    if (instance.web.currentform.model == 'hr_timesheet_sheet.sheet'){
+                        model = new instance.web.DataSet(self, instance.web.currentform.model);
+                        model.call('date_today', [instance.web.currentform.dataset.ids]).done(function(result){instance.web.currentform.reload();});
+                    }
+                    else{
+                        instance.web.currentform.reload();
+                    }
+                    
+                }
+            });
+        },
+        do_slide:function(attendance_state)
+        {
+            if(attendance_state == 'present'){
+                this.$oe_attendance_slider.attr("title",_t("Sign Out"));
+                this.$oe_attendance_slider.animate({"left": "48px"}, "slow");}
+            else{
+                this.$oe_attendance_slider.attr("title",_t("Sign In"));
+                this.$oe_attendance_slider.animate({"left": "-8px"}, "slow");}
+
+        },
+        check_attendance: function(){
+            var self = this;
+            self.employee = false;
+            this.$element.find(".oe_attendance_status").hide();
+            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']).pipe(function(res) {
+                if(_.isEmpty(res)) return;
+                self.$element.find(".oe_attendance_status").show();
+                self.employee = res[0];
+                self.do_slide(self.employee.state);
+            });
+        },
+    });
+    
+    instance.web.ListView.include({
+        init:function(parent, dataset, view_id, options)
+        {
+            this._super(parent, dataset, view_id, options);
+            if (this.model == 'hr.employee' || this.model == 'hr.attendance' || this.model == 'hr_timesheet_sheet.sheet')
+                instance.web.currentlist = this;
+        }
+    });
+    
+    
+    instance.web.FormView.include({
+        init: function(parent, dataset, view_id, options) {
+            this._super(parent, dataset, view_id, options);
+            if (this.model == 'hr.employee' || this.model == 'hr.attendance' || this.model == 'hr_timesheet_sheet.sheet')
+                instance.web.currentform = this;
+        },
+        reload: function(){
+            var re = this._super();
+            if (!instance.web.attendanceslider) return re;
+            if (this.model == 'hr.employee' || this.model == 'hr.attendance' || this.model == 'hr_timesheet_sheet.sheet')
+                instance.web.attendanceslider.check_attendance();            
+            return re;            
+        },                
+    }),
+    
+    instance.web.UserMenu.include({
+        do_update: function () {
+            this._super();
+            var self = this;
+            var fct = function() {                
+                instance.web.attendanceslider = new instance.hr_attendance.AttendanceSlider(self);
+                instance.web.attendanceslider.renderElement();
+                return instance.web.attendanceslider.check_attendance();                
+            };
+            this.update_promise = this.update_promise.pipe(fct, fct);
+        },
+    });
+}

=== added directory 'hr_attendance/static/src/xml'
=== added file 'hr_attendance/static/src/xml/attendance.xml'
--- hr_attendance/static/src/xml/attendance.xml	1970-01-01 00:00:00 +0000
+++ hr_attendance/static/src/xml/attendance.xml	2012-06-21 23:10:49 +0000
@@ -0,0 +1,17 @@
+<template>
+    
+    <t t-name="AttendanceSlider">
+         <li>
+               <div class="oe_attendance_status">
+                    <div class="oe_attendance_present"><t t-esc="present"/></div>
+                    <div class="oe_attendance_absent"><t t-esc="absent"/></div>
+                    <div class="oe_attendance_slider"><span  class="oe_attendance_text">slider</span></div>
+               </div>
+         </li>
+    </t>   
+</template>
+
+
+
+
+

=== modified file 'hr_attendance/test/attendance_process.yml'
--- hr_attendance/test/attendance_process.yml	2012-01-31 13:36:57 +0000
+++ hr_attendance/test/attendance_process.yml	2012-06-21 23:10:49 +0000
@@ -1,16 +1,8 @@
 -
   In order to test attendance process in OpenERP, I entry of SignIn of employee.
 -
-  !python {model: hr.sign.in.out}: |
-    context.update({'emp_id': [ref('hr.employee_al')]}) #TOFIX: emp_ids instead of 'emp_id'
--
-  !record {model: hr.sign.in.out, id: employee_sign_in}:
-    {}
--
-  Employee Signs In.
--
-  !python {model: hr.sign.in.out}: |
-    self.si_check(cr, uid, [ref("employee_sign_in")], context=context)
+  !python {model: hr.employee}: |
+    self.attendance_action_change(cr, uid, [ref("hr.employee_al")], context=context)
 -
   I check that Employee is "Present".
 -
@@ -19,10 +11,10 @@
 -
   After few seconds, employee sign's out.
 -
-  !python {model: hr.sign.in.out}: |
+  !python {model: hr.employee}: |
     import time
     time.sleep(2)
-    self.so_check(cr, uid, [ref("employee_sign_in")], context=context)
+    self.attendance_action_change(cr, uid, [ref("hr.employee_al")], context=context)
 -
   I check that Employee is "Absent".
 -

=== modified file 'hr_attendance/wizard/__init__.py'
--- hr_attendance/wizard/__init__.py	2011-01-14 00:11:01 +0000
+++ hr_attendance/wizard/__init__.py	2012-06-21 23:10:49 +0000
@@ -19,9 +19,8 @@
 #
 ##############################################################################
 
-import hr_attendance_sign_in_out
 import hr_attendance_error
 import hr_attendance_byweek
 import hr_attendance_bymonth
 
-# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
\ No newline at end of file
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

=== removed file 'hr_attendance/wizard/hr_attendance_sign_in_out.py'
--- hr_attendance/wizard/hr_attendance_sign_in_out.py	2011-11-09 18:12:56 +0000
+++ hr_attendance/wizard/hr_attendance_sign_in_out.py	1970-01-01 00:00:00 +0000
@@ -1,184 +0,0 @@
-# -*- coding: utf-8 -*-
-##############################################################################
-#
-#    OpenERP, Open Source Management Solution
-#    Copyright (C) 2004-2010 Tiny SPRL (<http://tiny.be>).
-#
-#    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/>.
-#
-##############################################################################
-import time
-
-from osv import osv, fields
-from tools.translate import _
-
-class hr_si_so_ask(osv.osv_memory):
-    _name = 'hr.sign.in.out.ask'
-    _description = 'Ask for Sign In Out'
-    _columns = {
-        'name': fields.char('Employees name', size=32, required=True, readonly=True),
-        'last_time': fields.datetime('Your last sign out', required=True),
-        'emp_id': fields.many2one('hr.employee', 'Empoyee ID', readonly=True),
-        }
-
-    def _get_empname(self, cr, uid, context=None):
-        emp_id = context.get('emp_id', self.pool.get('hr.employee').search(cr, uid, [('user_id', '=', uid)], context=context))
-        if emp_id:
-            employee = self.pool.get('hr.employee').browse(cr, uid, emp_id, context=context)[0].name
-            return employee
-        return ''
-
-    def _get_empid(self, cr, uid, context=None):
-        emp_id = context.get('emp_id', self.pool.get('hr.employee').search(cr, uid, [('user_id', '=', uid)], context=context))
-        if emp_id:
-            return emp_id[0]
-        return False
-
-    _defaults = {
-         'name': _get_empname,
-         'emp_id': _get_empid,
-                 }
-
-    def sign_in(self, cr, uid, ids, context=None):
-        data = self.read(cr, uid, ids, [], context=context)[0]
-        data['emp_id'] = data['emp_id'] and data['emp_id'][0]
-        return self.pool.get('hr.sign.in.out').sign_in(cr, uid, data, context)
-
-    def sign_out(self, cr, uid, ids, context=None):
-        data = self.read(cr, uid, ids, [], context=context)[0]
-        data['emp_id'] = data['emp_id'] and data['emp_id'][0]
-        return self.pool.get('hr.sign.in.out').sign_out(cr, uid, data, context)
-
-hr_si_so_ask()
-
-class hr_sign_in_out(osv.osv_memory):
-    _name = 'hr.sign.in.out'
-    _description = 'Sign In Sign Out'
-
-    _columns = {
-        'name': fields.char('Employees name', size=32, required=True, readonly=True),
-        'state': fields.char('Current state', size=32, required=True, readonly=True),
-        'emp_id': fields.many2one('hr.employee', 'Empoyee ID', readonly=True),
-                }
-
-    def _get_empid(self, cr, uid, context=None):
-        emp_id = context.get('emp_id', self.pool.get('hr.employee').search(cr, uid, [('user_id', '=', uid)], context=context))
-        if emp_id:
-            employee = self.pool.get('hr.employee').browse(cr, uid, emp_id, context=context)[0]
-            return {'name': employee.name, 'state': employee.state, 'emp_id': emp_id[0]}
-        return {}
-
-    def default_get(self, cr, uid, fields_list, context=None):
-        res = super(hr_sign_in_out, self).default_get(cr, uid, fields_list, context=context)
-        res_emp = self._get_empid(cr, uid, context=context)
-        res.update(res_emp)
-        return res
-
-    def si_check(self, cr, uid, ids, context=None):
-        obj_model = self.pool.get('ir.model.data')
-        att_obj = self.pool.get('hr.attendance')
-        data = self.read(cr, uid, ids, [], context=context)[0]
-        data['emp_id'] = data['emp_id'] and data['emp_id'][0]
-        emp_id = data['emp_id']
-        att_id = att_obj.search(cr, uid, [('employee_id', '=', emp_id)], limit=1, order='name desc')
-        last_att = att_obj.browse(cr, uid, att_id, context=context)
-        if last_att:
-            last_att = last_att[0]
-        cond = not last_att or last_att.action == 'sign_out'
-        if cond:
-            return self.sign_in(cr, uid, data, context)
-        else:
-            model_data_ids = obj_model.search(cr,uid,[('model','=','ir.ui.view'),('name','=','view_hr_attendance_so_ask')], context=context)
-            resource_id = obj_model.read(cr, uid, model_data_ids, fields=['res_id'], context=context)[0]['res_id']
-            return {
-                'name': _('Sign in / Sign out'),
-                'view_type': 'form',
-                'view_mode': 'tree,form',
-                'res_model': 'hr.sign.in.out.ask',
-                'views': [(resource_id,'form')],
-                'type': 'ir.actions.act_window',
-                'context': context,
-                'target': 'new',
-            }
-
-    def so_check(self, cr, uid, ids, context=None):
-        obj_model = self.pool.get('ir.model.data')
-        att_obj = self.pool.get('hr.attendance')
-        data = self.read(cr, uid, ids, [], context=context)[0]
-        data['emp_id'] = data['emp_id'] and data['emp_id'][0]
-        emp_id = data['emp_id']
-        att_id = att_obj.search(cr, uid, [('employee_id', '=', emp_id),('action', '!=', 'action')], limit=1, order='name desc')
-        last_att = att_obj.browse(cr, uid, att_id, context=context)
-        if last_att:
-            last_att = last_att[0]
-        if not att_id and not last_att:
-            model_data_ids = obj_model.search(cr, uid, [('model','=','ir.ui.view'),('name','=','view_hr_attendance_message')], context=context)
-            resource_id = obj_model.read(cr, uid, model_data_ids, fields=['res_id'], context=context)[0]['res_id']
-            return {
-                'name': _('Sign in / Sign out'),
-                'view_type': 'form',
-                'view_mode': 'tree,form',
-                'res_model': 'hr.sign.in.out',
-                'views': [(resource_id,'form')],
-                'type': 'ir.actions.act_window',
-                'context': context,
-                'target': 'new',
-            }
-
-        cond = last_att and last_att['action'] == 'sign_in'
-        if cond:
-            return self.sign_out(cr, uid, data, context)
-        else:
-            model_data_ids = obj_model.search(cr, uid, [('model','=','ir.ui.view'),('name','=','view_hr_attendance_si_ask')], context=context)
-            resource_id = obj_model.read(cr, uid, model_data_ids, fields=['res_id'], context=context)[0]['res_id']
-            return {
-                'name': _('Sign in / Sign out'),
-                'view_type': 'form',
-                'view_mode': 'tree,form',
-                'res_model': 'hr.sign.in.out.ask',
-                'views': [(resource_id,'form')],
-                'type': 'ir.actions.act_window',
-                'target': 'new',
-            }
-
-    def sign_in(self, cr, uid, data, context=None):
-        if context is None:
-            context = {}
-        emp_id = data['emp_id']
-        if 'last_time' in data:
-            if data['last_time'] > time.strftime('%Y-%m-%d %H:%M:%S'):
-                raise osv.except_osv(_('UserError'), _('The sign-out date must be in the past'))
-            self.pool.get('hr.attendance').create(cr, uid, {'name': data['last_time'], 'action': 'sign_out',
-                'employee_id': emp_id}, context=context)
-        try:
-            self.pool.get('hr.employee').attendance_action_change(cr, uid, [emp_id], 'sign_in')
-        except:
-            raise osv.except_osv(_('UserError'), _('A sign-in must be right after a sign-out !'))
-        return {'type': 'ir.actions.act_window_close'} # To do: Return Success message
-
-    def sign_out(self, cr, uid, data, context=None):
-        emp_id = data['emp_id']
-        if 'last_time' in data:
-            if data['last_time'] > time.strftime('%Y-%m-%d %H:%M:%S'):
-                raise osv.except_osv(_('UserError'), _('The Sign-in date must be in the past'))
-            self.pool.get('hr.attendance').create(cr, uid, {'name':data['last_time'], 'action':'sign_in',  'employee_id':emp_id}, context=context)
-        try:
-            self.pool.get('hr.employee').attendance_action_change(cr, uid, [emp_id], 'sign_out')
-        except:
-            raise osv.except_osv(_('UserError'), _('A sign-out must be right after a sign-in !'))
-        return {'type': 'ir.actions.act_window_close'} # To do: Return Success message
-
-hr_sign_in_out()
-
-# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

=== removed file 'hr_attendance/wizard/hr_attendance_sign_in_out_view.xml'
--- hr_attendance/wizard/hr_attendance_sign_in_out_view.xml	2012-06-13 13:52:48 +0000
+++ hr_attendance/wizard/hr_attendance_sign_in_out_view.xml	1970-01-01 00:00:00 +0000
@@ -1,95 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<openerp>
-    <data>
-        <record id="view_hr_attendance_sigh_in_out" model="ir.ui.view">
-            <field name="name">hr.sign.in.out.form</field>
-            <field name="model">hr.sign.in.out</field>
-            <field name="type">form</field>
-            <field name="arch" type="xml">
-                <form string="Sign in / Sign out">
-                    <separator colspan="4" string="Sign in / Sign out"/>
-                    <label colspan="4" nolabel="1" string="If you need your staff to sign in when they arrive at work and sign out again at the end of the day, OpenERP allows you to manage this with this tool. If each employee has been linked to a system user, then they can encode their time with this action button."/>
-                    <newline/>
-                    <group colspan="4" >
-                    <field name="name" />
-                    <field name="state" />
-                    </group>
-                    <separator colspan="4"/>
-                    <group colspan="4" col="6">
-                        <button icon="gtk-cancel" special="cancel" string="Cancel"/>
-                        <button icon="terp-gtk-jump-to-ltr" string="Sign in" name="si_check" type="object"/>
-                        <button icon="terp-gtk-jump-to-rtl" string="Sign out" name="so_check" type="object"/>
-                   </group>
-               </form>
-            </field>
-        </record>
-
-       <record id="view_hr_attendance_message" model="ir.ui.view">
-            <field name="name">hr.sign.in.out.form</field>
-            <field name="model">hr.sign.in.out</field>
-            <field name="type">form</field>
-            <field name="arch" type="xml">
-                <form string="Sign in / Sign out">
-                    <separator string="Sign-out Entry Must Follow Sign-in." colspan="4" />
-                    <group colspan="4" col="6">
-                        <button icon="gtk-cancel" special="cancel" string="Ok"/>
-                   </group>
-               </form>
-            </field>
-        </record>
-
-        <record id="action_hr_attendance_sigh_in_out" model="ir.actions.act_window">
-            <field name="name">Sign in / Sign out</field>
-            <field name="res_model">hr.sign.in.out</field>
-            <field name="view_type">form</field>
-            <field name="view_mode">tree,form</field>
-           <field name="view_id" ref="view_hr_attendance_sigh_in_out"/>
-           <field name="target">new</field>
-           <field name="help">Sign in / Sign out. In some companies, staff have to sign in when they arrive at work and sign out again at the end of the day. If each employee has been linked to a system user, then they can encode their time with this action button.</field>
-        </record>
-
-        <menuitem action="action_hr_attendance_sigh_in_out" id="menu_hr_attendance_sigh_in_out"
-            parent="menu_hr_attendance" sequence="4"/>
-
-       <record id="view_hr_attendance_so_ask" model="ir.ui.view">
-            <field name="name">hr.sign.in.out.ask.form</field>
-            <field name="model">hr.sign.in.out.ask</field>
-            <field name="type">form</field>
-            <field name="arch" type="xml">
-                <form string="hr.sign.out.ask">
-                    <group colspan="4" >
-                    <separator string="You did not sign out the last time. Please enter the date and time you signed out." colspan="4" />
-                    <field name="name" />
-                    <field name="last_time" string="Your last sign out" />
-                    </group>
-                    <separator colspan="4" />
-                    <group colspan="4" col="6">
-                        <button icon="gtk-cancel" special="cancel" string="Cancel"/>
-                        <button icon="gtk-go-back" string="Sign in" name="sign_in" type="object"/>
-                   </group>
-               </form>
-            </field>
-        </record>
-
-       <record id="view_hr_attendance_si_ask" model="ir.ui.view">
-            <field name="name">hr.sign.in.out.ask.form</field>
-            <field name="model">hr.sign.in.out.ask</field>
-            <field name="type">form</field>
-            <field name="arch" type="xml">
-                <form string="hr.sign.in.out.ask">
-                    <group colspan="4" >
-                    <separator string="You did not sign in the last time. Please enter the date and time you signed in." colspan="4" />
-                    <field name="name" />
-                    <field name="last_time" string="Your last sign in" />
-                    </group>
-                    <separator colspan="4" />
-                    <group colspan="4" col="6">
-                        <button icon="gtk-cancel" special="cancel" string="Cancel"/>
-                        <button icon="gtk-go-back" string="Sign out" name="sign_out" type="object"/>
-                   </group>
-               </form>
-            </field>
-        </record>
-
-    </data>
-</openerp>

=== modified file 'hr_timesheet/wizard/hr_timesheet_sign_in_out.py'
--- hr_timesheet/wizard/hr_timesheet_sign_in_out.py	2011-12-21 10:52:14 +0000
+++ hr_timesheet/wizard/hr_timesheet_sign_in_out.py	2012-06-21 23:10:49 +0000
@@ -91,7 +91,7 @@
         emp_obj = self.pool.get('hr.employee')
         for data in self.browse(cr, uid, ids, context=context):
             emp_id = data.emp_id.id
-            emp_obj.attendance_action_change(cr, uid, [emp_id], type='sign_out', dt=data.date)
+            emp_obj.attendance_action_change(cr, uid, [emp_id], {'action':'sign_out', 'action_date':data.date})
             self._write(cr, uid, data, emp_id, context=context)
         return {'type': 'ir.actions.act_window_close'}
 
@@ -99,7 +99,7 @@
         emp_obj = self.pool.get('hr.employee')
         for data in self.browse(cr, uid, ids, context=context):
             emp_id = data.emp_id.id
-            emp_obj.attendance_action_change(cr, uid, [emp_id], type='action', dt=data.date)
+            emp_obj.attendance_action_change(cr, uid, [emp_id], {'action':'action', 'action_date':data.date})
             self._write(cr, uid, data, emp_id, context=context)
         return {'type': 'ir.actions.act_window_close'}
 
@@ -156,7 +156,7 @@
         emp_obj = self.pool.get('hr.employee')
         for data in self.browse(cr, uid, ids, context=context):
             emp_id = data.emp_id.id
-            emp_obj.attendance_action_change(cr, uid, [emp_id], type = 'sign_in' ,dt=data.date or False)
+            emp_obj.attendance_action_change(cr, uid, [emp_id], {'action':'sign_in', 'action_date':data.date})
         return {'type': 'ir.actions.act_window_close'}
 
     def default_get(self, cr, uid, fields_list, context=None):

=== modified file 'hr_timesheet_sheet/hr_timesheet_sheet.py'
--- hr_timesheet_sheet/hr_timesheet_sheet.py	2012-05-04 11:57:48 +0000
+++ hr_timesheet_sheet/hr_timesheet_sheet.py	2012-06-21 23:10:49 +0000
@@ -312,31 +312,14 @@
                 self.write(cr, uid, [sheet.id], {'date_current': sheet.date_to,}, context=context)
         return True
 
-    def check_sign(self, cr, uid, ids, typ, context=None):
-        sheet = self.browse(cr, uid, ids, context=context)[0]
-        if not sheet.date_current == time.strftime('%Y-%m-%d'):
-            raise osv.except_osv(_('Error !'), _('You cannot sign in/sign out from an other date than today'))
-        return True
-
-    def sign(self, cr, uid, ids, typ, context=None):
-        self.check_sign(cr, uid, ids, typ, context=context)
-        sign_obj = self.pool.get('hr.sign.in.out')
-        sheet = self.browse(cr, uid, ids, context=context)[0]
-        context['emp_id'] = [sheet.employee_id.id]
-        sign_id = sign_obj.create(cr, uid, {}, context=context)
-        methods = {'sign_in': sign_obj.si_check,
-                   'sign_out': sign_obj.so_check}
-        wizard_result = methods[typ](cr, uid, [sign_id], context=context)
-        if wizard_result.get('type', False) == 'ir.actions.act_window_close':
-            return True  # ensure we do not close the main window !
-        wizard_result['nodestroy'] = True  # do not destroy the main window !
-        return wizard_result
-
-    def sign_in(self, cr, uid, ids, context=None):
-        return self.sign(cr, uid, ids, 'sign_in', context=context)
-
-    def sign_out(self, cr, uid, ids, context=None):
-        return self.sign(cr, uid, ids, 'sign_out', context=context)
+    
+    def attendance_action_change(self, cr, uid, ids, context=None):
+        hr_employee = self.pool.get('hr.employee')
+        employee_ids = []
+        for sheet in self.browse(cr, uid, ids, context=context):
+            if sheet.employee_id.id not in employee_ids: employee_ids.append(sheet.employee_id.id)
+        return hr_employee.attendance_action_change(cr, uid, employee_ids, context=context)
+
 
     _columns = {
         'name': fields.char('Note', size=64, select=1,

=== modified file 'hr_timesheet_sheet/hr_timesheet_sheet_demo.xml'
--- hr_timesheet_sheet/hr_timesheet_sheet_demo.xml	2011-12-22 13:35:59 +0000
+++ hr_timesheet_sheet/hr_timesheet_sheet_demo.xml	2012-06-21 23:10:49 +0000
@@ -2,12 +2,12 @@
 <openerp>
     <data noupdate="1">
         
-        <record id="sheet1" model="hr_timesheet_sheet.sheet">
+<!--        <record id="sheet1" model="hr_timesheet_sheet.sheet">
             <field name="name">Sheet 1</field>
             <field name="user_id" ref="base.user_root"/>
             <field name="employee_id" ref="hr.employee_fp" />
             <field eval="time.strftime('%Y-%m-%d')" name="date_current"/>
         </record>
-
+-->
     </data>
 </openerp>

=== modified file 'hr_timesheet_sheet/hr_timesheet_sheet_view.xml'
--- hr_timesheet_sheet/hr_timesheet_sheet_view.xml	2012-06-21 05:08:52 +0000
+++ hr_timesheet_sheet/hr_timesheet_sheet_view.xml	2012-06-21 23:10:49 +0000
@@ -92,8 +92,8 @@
                             </field>
                             <group col="4" colspan="1">
                                 <field name="state_attendance"/>
-                                <button name="sign_in" string="Sign In" type="object" icon="terp-gtk-jump-to-ltr"/>
-                                <button name="sign_out" string="Sign Out" type="object" icon="terp-gtk-jump-to-rtl"/>
+                                <button name="attendance_action_change" attrs="{'invisible': ['|', ('state_attendance','=',False), ('state_attendance', '=', 'absent')]}" type="object" string="Sign Out" groups="base.group_hr_manager"/>
+                                <button name="attendance_action_change" attrs="{'invisible': [('state_attendance', '=', 'present')]}" type="object" string="Sign In" groups="base.group_hr_manager"/>
                                 <field name="total_attendance_day" widget="float_time" colspan="4"/>
                             </group>
                             <field colspan="4" context="{'date':date_current,'user_id':user_id}" domain="[('name','=',date_current)]" name="timesheet_ids" nolabel="1">

=== modified file 'hr_timesheet_sheet/test/test_hr_timesheet_sheet.yml'
--- hr_timesheet_sheet/test/test_hr_timesheet_sheet.yml	2012-03-14 17:00:50 +0000
+++ hr_timesheet_sheet/test/test_hr_timesheet_sheet.yml	2012-06-21 23:10:49 +0000
@@ -26,7 +26,7 @@
   Now, at the time of login, I create Attendances and perform "Sign In" action.
 -
   !python {model: hr_timesheet_sheet.sheet}: |
-    self.sign_in(cr, uid, [ref('hr_timesheet_sheet_sheet_deddk0')], {})
+    self.attendance_action_change(cr, uid, [ref('hr_timesheet_sheet_sheet_deddk0')], {})
     task_work = self.search(cr, uid, [("name","=","Quentin Paolinon")],context)[0]
     task_ids = self.browse(cr, uid, task_work, context)
     assert task_ids.state == "draft", "I State In Timesheet"

_______________________________________________
Mailing list: https://launchpad.net/~openerp-dev-gtk
Post to     : [email protected]
Unsubscribe : https://launchpad.net/~openerp-dev-gtk
More help   : https://help.launchpad.net/ListHelp

Reply via email to