diff --git a/addons/hr_attendance/__openerp__.py b/addons/hr_attendance/__openerp__.py index 985c42e5a04..cb2cd261773 100644 --- a/addons/hr_attendance/__openerp__.py +++ b/addons/hr_attendance/__openerp__.py @@ -43,7 +43,6 @@ 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', - 'wizard/hr_attendance_sign_in_out_view.xml', ], 'demo': ['hr_attendance_demo.xml'], 'test': [ @@ -53,5 +52,10 @@ actions(Sign in/Sign out) performed by them. '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: diff --git a/addons/hr_attendance/hr_attendance.py b/addons/hr_attendance/hr_attendance.py index 7a0cc7a8e51..ae05a6143fd 100644 --- a/addons/hr_attendance/hr_attendance.py +++ b/addons/hr_attendance/hr_attendance.py @@ -122,30 +122,25 @@ class hr_employee(osv.osv): 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 = {} + 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' - #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,)) + 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],)) - 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 + 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() diff --git a/addons/hr_attendance/hr_attendance_view.xml b/addons/hr_attendance/hr_attendance_view.xml index 1d0122d55fa..097d7f32258 100644 --- a/addons/hr_attendance/hr_attendance_view.xml +++ b/addons/hr_attendance/hr_attendance_view.xml @@ -127,8 +127,8 @@