diff --git a/addons/hr_attendance/__openerp__.py b/addons/hr_attendance/__openerp__.py index 0947f208be6..eec95887bb8 100644 --- a/addons/hr_attendance/__openerp__.py +++ b/addons/hr_attendance/__openerp__.py @@ -44,7 +44,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_xml': ['hr_attendance_demo.xml'], 'test': [ @@ -57,7 +56,6 @@ actions(Sign in/Sign out) performed by them. #web "js": ["static/src/js/attendance.js"], - "css":["static/src/css/attendance.css"], 'qweb' : ["static/src/xml/attendance.xml"], } # 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 08323ce7847..e3ba69ba437 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 7c29ff8c404..9fc554472e9 100644 --- a/addons/hr_attendance/hr_attendance_view.xml +++ b/addons/hr_attendance/hr_attendance_view.xml @@ -130,8 +130,8 @@ -