diff options
| author | Christophe Simonis <chs@openerp.com> | 2012-12-14 16:54:30 +0100 |
|---|---|---|
| committer | Christophe Simonis <chs@openerp.com> | 2012-12-14 16:54:30 +0100 |
| commit | c4e89c651aefad5efa5a1143403ac0df2d492f10 (patch) | |
| tree | 6c7e2da09f0c97622e28584d21d36d261a3508f6 | |
| parent | d6087e208fa372f12536c30342deb898d3883c6f (diff) | |
| parent | 2c8f4f75729c20ff9c43dff100e3eb97e86ffd5e (diff) | |
[FIX] hr_attendance: do not show slider widget if user is not an employee
bzr revid: chs@openerp.com-20121214155430-h6u3l9jlutm1dclw
| -rw-r--r-- | addons/hr_attendance/static/src/js/attendance.js | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/addons/hr_attendance/static/src/js/attendance.js b/addons/hr_attendance/static/src/js/attendance.js index 84516353b9d..c2750a920a4 100644 --- a/addons/hr_attendance/static/src/js/attendance.js +++ b/addons/hr_attendance/static/src/js/attendance.js @@ -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(); @@ -75,13 +75,21 @@ openerp.hr_attendance = function (instance) { do_update: function () { this._super(); var self = this; - this.update_promise = this.update_promise.done(function () { - if (self.attendanceslider) + this.update_promise.done(function () { + if (!_.isUndefined(self.attendanceslider)) { return; - self.attendanceslider = new instance.hr_attendance.AttendanceSlider(self); - - self.attendanceslider.prependTo(instance.webclient.$('.oe_systray')); + } + // check current user is an employee + var Users = new instance.web.Model('res.users'); + Users.call('has_group', ['base.group_user']).done(function(is_employee) { + if (is_employee) { + self.attendanceslider = new instance.hr_attendance.AttendanceSlider(self); + self.attendanceslider.prependTo(instance.webclient.$('.oe_systray')); + } else { + self.attendanceslider = null; + } + }); }); }, }); -} +}; |
