diff options
| author | Géry Debongnie <ged@odoo.com> | 2016-03-03 12:23:56 +0100 |
|---|---|---|
| committer | Géry Debongnie <ged@odoo.com> | 2016-05-30 11:43:06 +0200 |
| commit | 2f7bd4d7e9e67849d002a0081fde8e4fdda6ec86 (patch) | |
| tree | 546d9f95c30f20f86e102d3a77da5e9afba38955 /addons | |
| parent | f3fb0bfe29bcc02715a42a5f7f4e2446a109c8e3 (diff) | |
[IMP] hr_attendance: remove extra rpc
The attendance module needs to know if the user is an employee before
putting itself in the systray. This commit add the information in the
session infos, and use it directly.
Diffstat (limited to 'addons')
| -rw-r--r-- | addons/hr_attendance/__init__.py | 2 | ||||
| -rw-r--r-- | addons/hr_attendance/models/__init__.py | 4 | ||||
| -rw-r--r-- | addons/hr_attendance/models/hr_attendance.py (renamed from addons/hr_attendance/hr_attendance.py) | 0 | ||||
| -rw-r--r-- | addons/hr_attendance/models/ir_http.py | 9 | ||||
| -rw-r--r-- | addons/hr_attendance/static/src/js/attendance.js | 9 |
5 files changed, 18 insertions, 6 deletions
diff --git a/addons/hr_attendance/__init__.py b/addons/hr_attendance/__init__.py index 86c96b3c9a2..bd6cae5c16b 100644 --- a/addons/hr_attendance/__init__.py +++ b/addons/hr_attendance/__init__.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- # Part of Odoo. See LICENSE file for full copyright and licensing details. -import hr_attendance import wizard import report +import models diff --git a/addons/hr_attendance/models/__init__.py b/addons/hr_attendance/models/__init__.py new file mode 100644 index 00000000000..eeef82d250c --- /dev/null +++ b/addons/hr_attendance/models/__init__.py @@ -0,0 +1,4 @@ +# -*- coding: utf-8 -*- + +import hr_attendance +import ir_http diff --git a/addons/hr_attendance/hr_attendance.py b/addons/hr_attendance/models/hr_attendance.py index cd8bae0e1a1..cd8bae0e1a1 100644 --- a/addons/hr_attendance/hr_attendance.py +++ b/addons/hr_attendance/models/hr_attendance.py diff --git a/addons/hr_attendance/models/ir_http.py b/addons/hr_attendance/models/ir_http.py new file mode 100644 index 00000000000..b321ca723f7 --- /dev/null +++ b/addons/hr_attendance/models/ir_http.py @@ -0,0 +1,9 @@ +from openerp import models, service + +class Http(models.Model): + _inherit = 'ir.http' + + def session_info(self): + result = super(Http, self).session_info() + result['is_employee'] = self.env.user.has_group('base.group_user') + return result diff --git a/addons/hr_attendance/static/src/js/attendance.js b/addons/hr_attendance/static/src/js/attendance.js index 03ca6a8644b..355afc04c7f 100644 --- a/addons/hr_attendance/static/src/js/attendance.js +++ b/addons/hr_attendance/static/src/js/attendance.js @@ -4,7 +4,7 @@ odoo.define('hr_attendance.hr_attendance', function(require) { var core = require('web.core'); var data = require('web.data'); var formats = require('web.formats'); -var Model = require('web.DataModel'); +var session = require('web.session'); var SystrayMenu = require('web.SystrayMenu'); var time = require('web.time'); var Widget = require('web.Widget'); @@ -75,10 +75,9 @@ var AttendanceSlider = Widget.extend({ }, }); -// Put the AttendanceSlider widget in the systray menu if the user is an employee -var Users = new Model('res.users'); -Users.call('has_group', ['base.group_user']).done(function(is_employee) { - if (is_employee) { +session.is_bound.then(function () { + // Put the AttendanceSlider widget in the systray menu if the user is an employee + if (session.is_employee) { SystrayMenu.Items.push(AttendanceSlider); } }); |
