diff --git a/addons/hr_attendance/hr_attendance_view.xml b/addons/hr_attendance/hr_attendance_view.xml
index 258177bfd5e..7c29ff8c404 100644
--- a/addons/hr_attendance/hr_attendance_view.xml
+++ b/addons/hr_attendance/hr_attendance_view.xml
@@ -130,8 +130,8 @@
-
-
+
+
diff --git a/addons/hr_attendance/static/src/css/attendance.css b/addons/hr_attendance/static/src/css/attendance.css
index 5300129b54b..48de536f59c 100644
--- a/addons/hr_attendance/static/src/css/attendance.css
+++ b/addons/hr_attendance/static/src/css/attendance.css
@@ -1,4 +1,4 @@
.oe_attendance_button {
- cursor: 'pointer';
+ cursor:pointer;
}
diff --git a/addons/hr_attendance/static/src/js/attendance.js b/addons/hr_attendance/static/src/js/attendance.js
index 778a2fb5546..e447ca1dc7e 100644
--- a/addons/hr_attendance/static/src/js/attendance.js
+++ b/addons/hr_attendance/static/src/js/attendance.js
@@ -2,11 +2,6 @@ openerp.hr_attendance = function(instance) {
var QWeb = instance.web.qweb;
instance.hr_attendance.AttendanceNotifier = instance.web.Widget.extend({
template: 'AttendanceNotifier',
- init: function(parent){
- this._super(parent);
- this.session = parent.session;
- this.employee = new instance.web.DataSetSearch(this, 'hr.employee', this.session.user_context, [['user_id','=', this.session.uid]]);
- },
renderElement: function() {
var self = this;
if (this.attendance_status == 'present'){
@@ -33,29 +28,44 @@ openerp.hr_attendance = function(instance) {
action = action[0];
action.context = JSON.parse(action.context);
var action_manager = new instance.web.ActionManager(self);
- action_manager.do_action(action, function(){
- self.employee.read_slice(['state']).done(function(employee) {
- if(_.isEmpty(employee)) return;
- self.attendance_status = employee[0]['state'];
- self.renderElement();
- });
- });
+ action_manager.do_action(action);
});
},
});
+ instance.hr_attendance.AttendanceStatus = instance.web.Class.extend({
+ init: function(parent){
+ this.session = parent.session;
+ attendance = new instance.hr_attendance.AttendanceNotifier(self);
+ employee = new instance.web.DataSetSearch(this, 'hr.employee', this.session.user_context, [['user_id','=', this.session.uid]]);
+ employee.read_slice(['state']).done(function(employee) {
+ if(_.isEmpty(employee)) return;
+ attendance.attendance_status = employee[0]['state'];
+ attendance.renderElement();
+ });
+ },
+ });
+
+ instance.web.ActionManager.include({
+ do_action: function(action, on_close) {
+ var self = this;
+ if (action.res_model == "hr.sign.in.out"){
+ var old_close = on_close;
+ on_close = function(){
+ if(old_close){old_close();}
+ new instance.hr_attendance.AttendanceStatus(self);
+ }
+ }
+ this._super(action, on_close);
+ },
+ });
instance.web.UserMenu.include({
do_update: function() {
var self = this;
this._super();
this.update_promise.then(function() {
- attendance = new instance.hr_attendance.AttendanceNotifier(self);
- attendance.employee.read_slice(['state']).done(function(employee) {
- if(_.isEmpty(employee)) return;
- attendance.attendance_status = employee[0]['state'];
- attendance.renderElement();
- });
+ new instance.hr_attendance.AttendanceStatus(self);
});
},
});
diff --git a/addons/hr_attendance/wizard/hr_attendance_sign_in_out.py b/addons/hr_attendance/wizard/hr_attendance_sign_in_out.py
index 55edb1406e8..6ed02deb86c 100644
--- a/addons/hr_attendance/wizard/hr_attendance_sign_in_out.py
+++ b/addons/hr_attendance/wizard/hr_attendance_sign_in_out.py
@@ -71,7 +71,7 @@ class hr_sign_in_out(osv.osv_memory):
'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:
@@ -82,6 +82,13 @@ class hr_sign_in_out(osv.osv_memory):
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)
+ act_obj=self.pool.get('ir.actions.act_window')
+ action_id = act_obj.search(cr, uid, [('res_model','=','hr.sign.in.out')],context=context)
+ action = act_obj.browse(cr, uid, action_id[0], context=context)
+ if res_emp['state']=='present':
+ name = act_obj.write(cr, uid, action_id[0], {'name':'Sign Out'}, context=context)
+ if res_emp['state']=='absent':
+ name = act_obj.write(cr, uid, action_id[0], {'name':'Sign In'}, context=context)
res.update(res_emp)
return res
@@ -102,7 +109,7 @@ class hr_sign_in_out(osv.osv_memory):
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'),
+ 'name': _('Sign in '),
'view_type': 'form',
'view_mode': 'tree,form',
'res_model': 'hr.sign.in.out.ask',
diff --git a/addons/hr_attendance/wizard/hr_attendance_sign_in_out_view.xml b/addons/hr_attendance/wizard/hr_attendance_sign_in_out_view.xml
index 8d4b9ff0123..b3cffa9ab02 100644
--- a/addons/hr_attendance/wizard/hr_attendance_sign_in_out_view.xml
+++ b/addons/hr_attendance/wizard/hr_attendance_sign_in_out_view.xml
@@ -38,7 +38,7 @@
- Sign in / Sign out
+ Sign In / Sign Out
hr.sign.in.out
form
tree,form
@@ -47,8 +47,6 @@
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.
-
hr.sign.in.out.ask.form
diff --git a/addons/hr_timesheet_sheet/hr_timesheet_sheet_view.xml b/addons/hr_timesheet_sheet/hr_timesheet_sheet_view.xml
index c577e33f9c6..f325113bc21 100644
--- a/addons/hr_timesheet_sheet/hr_timesheet_sheet_view.xml
+++ b/addons/hr_timesheet_sheet/hr_timesheet_sheet_view.xml
@@ -91,8 +91,8 @@
-
-
+
+