[IMP] Web addon for SignIn/Out.

bzr revid: vda@tinyerp.com-20120406061330-n80vyxgkr309ykba
This commit is contained in:
Vaibhav (OpenERP) 2012-04-06 11:43:30 +05:30
parent c55b2e0ef2
commit 55e7b8167e
10 changed files with 121 additions and 5 deletions

View File

@ -54,5 +54,9 @@ actions(Sign in/Sign out) performed by them.
'installable': True,
'auto_install': False,
'certificate': '0063495605613',
#web
"js": ["static/src/js/sign_in_out.js"],
'qweb' : ["static/src/xml/sign_in_out.xml"],
}
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.8 KiB

View File

@ -0,0 +1,82 @@
openerp.hr_attendance = function(openerp) {
openerp.hr_attendance.SignIn = openerp.web.Widget.extend({
template: 'SignInNotifier',
start: function() {
this.$element.on('click', '.sign_in', this.getParent().on_sign_in_out);
}
});
openerp.hr_attendance.SignOut = openerp.web.Widget.extend({
template: 'SignOutNotifier',
start: function() {
this.$element.on('click', '.sign_out', this.getParent().on_sign_in_out);
}
});
openerp.hr_attendance.SignInOut = openerp.web.Widget.extend({
template: "SignInOutNotifier",
init: function() {
this._super.apply(this, arguments);
this.dataset = new openerp.web.DataSetSearch(
this,
'hr.employee',
this.session.user_context,
[['user_id','=', this.session.uid]]);
},
start: function() {
return this.dataset.read_slice(['state']).done(this.do_sign_in_out);
},
do_sign_in_out: function(user) {
if(_.isEmpty(user)) return;
if(user[0]['state'] === 'present') {
this.sign_out = new openerp.hr_attendance.SignOut(this);
this.sign_out.appendTo(this.$element);
} else {
this.sign_in = new openerp.hr_attendance.SignIn(this);
this.sign_in.appendTo(this.$element);
}
},
on_sign_in_out: function(evt) {
var self = this;
new openerp.web.DataSetSearch(
this,
'ir.actions.act_window',
{},
[['res_model', '=', 'hr.sign.in.out']])
.read_slice().done(function(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);
});
},
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);
}
}
});
openerp.web.UserMenu.include({
do_update: function() {
var self = this;
this._super();
this.update_promise.then(function() {
self.hr_sign_in_out = new openerp.hr_attendance.SignInOut(self);
self.hr_sign_in_out.appendTo(openerp.webclient.$element.find('.oe_systray'))
});
}
});
}

View File

@ -0,0 +1,28 @@
<template>
<t t-name="SignInOutNotifier">
<div>
</div>
</t>
<t t-name="SignInNotifier">
<div class="oe_hr_sign_in" title="SignIn">
<a class="sign_in" href="#">
<img
src='/hr_attendance/static/src/img/emp-in.png'
width="30"
height="30"/>
</a>
</div>
</t>
<t t-name="SignOutNotifier">
<div class="oe_hr_sign_out" title="SignOut">
<a class="sign_out" href="#">
<img
src='/hr_attendance/static/src/img/emp-out.png'
width="30"
height="30"/>
</a>
</div>
</t>
</template>

View File

@ -69,6 +69,7 @@ class hr_sign_in_out(osv.osv_memory):
_columns = {
'name': fields.char('Employees name', size=32, required=True, readonly=True),
'state': fields.char('Current state', size=32, required=True, readonly=True),
'date': fields.datetime('Date'),
'emp_id': fields.many2one('hr.employee', 'Empoyee ID', readonly=True),
}

View File

@ -10,15 +10,16 @@
<separator colspan="4" string="Sign in / Sign out"/>
<label colspan="4" nolabel="1" string="If you need your staff to sign in when they arrive at work and sign out again at the end of the day, OpenERP allows you to manage this with this tool. If each employee has been linked to a system user, then they can encode their time with this action button."/>
<newline/>
<group colspan="4" >
<field name="name" />
<field name="state" />
<group colspan="4" col="6">
<field name="date"/>
<field name="name" />
<field name="state" />
</group>
<separator colspan="4"/>
<group colspan="4" col="6">
<button icon="gtk-cancel" special="cancel" string="Cancel"/>
<button icon="terp-gtk-jump-to-ltr" string="Sign in" name="si_check" type="object"/>
<button icon="terp-gtk-jump-to-rtl" string="Sign out" name="so_check" type="object"/>
<button icon="terp-gtk-jump-to-ltr" string="Sign in" name="si_check" type="object" attrs="{'invisible':[('state','=','present')]}"/>
<button icon="terp-gtk-jump-to-rtl" string="Sign out" name="so_check" type="object" attrs="{'invisible':[('state','=','absent')]}"/>
</group>
</form>
</field>