[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.
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import hr_attendance
|
||||
import ir_http
|
||||
@@ -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
|
||||
@@ -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);
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user