[FIX] hr_attendance: do not show slider widget if user is not an employee
bzr revid: chs@openerp.com-20121213161351-27jx0l3utfzavaeo
This commit is contained in:
parent
a32f7d22b5
commit
e8832cb0cb
|
@ -60,7 +60,7 @@ openerp.hr_attendance = function (instance) {
|
|||
return employee.read_slice(['id', 'name', 'state', 'last_sign', 'attendance_access']).then(function (res) {
|
||||
if (_.isEmpty(res) )
|
||||
return;
|
||||
if (res[0].attendance_access == false){
|
||||
if (res[0].attendance_access === false){
|
||||
return;
|
||||
}
|
||||
self.$el.show();
|
||||
|
@ -72,16 +72,36 @@ openerp.hr_attendance = function (instance) {
|
|||
});
|
||||
|
||||
instance.web.UserMenu.include({
|
||||
|
||||
is_employee: function() {
|
||||
var self = this;
|
||||
if (_.isUndefined(self._is_employee)) {
|
||||
var Users = new instance.web.Model('res.users');
|
||||
return Users.query(['employee']).filter([['id', '=', self.session.uid]]).all().then(function(records) {
|
||||
if (_.isEmpty(records)) {
|
||||
self._is_employee = false;
|
||||
} else {
|
||||
self._is_employee = records[0].employee;
|
||||
}
|
||||
return self._is_employee;
|
||||
});
|
||||
} else {
|
||||
return $.Deferred().resolve(self._is_employee).promise();
|
||||
}
|
||||
},
|
||||
|
||||
do_update: function () {
|
||||
this._super();
|
||||
var self = this;
|
||||
this.update_promise = this.update_promise.done(function () {
|
||||
if (self.attendanceslider)
|
||||
return;
|
||||
self.attendanceslider = new instance.hr_attendance.AttendanceSlider(self);
|
||||
|
||||
self.attendanceslider.prependTo(instance.webclient.$('.oe_systray'));
|
||||
this.update_promise.done(function () {
|
||||
$.when(self.is_employee()).done(function(is_employee) {
|
||||
if (!is_employee || self.attendanceslider) {
|
||||
return;
|
||||
}
|
||||
self.attendanceslider = new instance.hr_attendance.AttendanceSlider(self);
|
||||
self.attendanceslider.prependTo(instance.webclient.$('.oe_systray'));
|
||||
});
|
||||
});
|
||||
},
|
||||
});
|
||||
}
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue