[IMP]changing icon on basis of state of user

bzr revid: dhr@tinyerp.com-20120504132119-0vc01xawt325w0nc
This commit is contained in:
Dharti Ratani (OpenERP) 2012-05-04 18:51:19 +05:30
parent 05fa2790ef
commit 5f34ed93fb
1 changed files with 7 additions and 15 deletions

View File

@ -24,7 +24,6 @@ openerp.hr_attendance = function(openerp) {
this._super(parent)
this.event = event
},
start: function() {
this.$element.on('click', this.event);
},
@ -57,13 +56,15 @@ openerp.hr_attendance = function(openerp) {
start: function() {
var self = this;
//console.log('stttarrrttttt',this.dataset)
return this.dataset.read_slice(['state']).done(this.do_sign_in_out);
},
do_sign_in_out: function(user) {
if(_.isEmpty(user)) return;
this.$element.html("");
if(user[0]['state'] === 'present') {
this.sign_out = new openerp.hr_attendance.SignOut(this, this.on_sign_in_out);
this.sign_out = new openerp.hr_attendance.SignOut(this, this.on_sign_in_out);
this.sign_out.appendTo(this.$element);
} else {
this.sign_in = new openerp.hr_attendance.SignIn(this, this.on_sign_in_out);
@ -79,24 +80,15 @@ openerp.hr_attendance = function(openerp) {
{},
[['res_model', '=', 'hr.sign.in.out']])
.read_slice().done(function(action) {
console.log('action',action);
action = action[0];
action.context = JSON.parse(action.context);
var action_manager = new openerp.web.ActionManager(self);
action_manager.do_action(action, self.on_close);
action_manager.do_action(action, function() {
self.dataset.read_slice(['state']).done(self.do_sign_in_out);
});
});
},
on_close: function() {
if(this.sign_in) {
this.sign_in.destroy();
this.sign_out = new openerp.hr_attendance.SignOut(this);
this.sign_out.appendTo(this.$element);
} else if(this.sign_out) {
this.sign_out.destroy();
this.sign_in = new openerp.hr_attendance.SignIn(this);
this.sign_in.appendTo(this.$element);
}
}
});