mirror of
https://gitlab.com/hibou-io/hibou-odoo/suite.git
synced 2025-01-20 12:37:31 +02:00
[IMP] hr_attendance_work_entry: Modified kiosk mode views and attendance views to allow for various punch types.
This commit is contained in:
committed by
Jared Kipe
parent
87ac2897f3
commit
d52761f5bc
71
hr_attendance_work_entry/static/src/js/kiosk_confirm.js
Normal file
71
hr_attendance_work_entry/static/src/js/kiosk_confirm.js
Normal file
@@ -0,0 +1,71 @@
|
||||
odoo.define('hr_attendance_work_entry.kiosk_confirm', function (require) {
|
||||
"use strict";
|
||||
|
||||
var core = require('web.core');
|
||||
var KioskConfirm = require('hr_attendance.kiosk_confirm');
|
||||
var KioskConfirmTyped = KioskConfirm.extend({
|
||||
events: _.extend({}, KioskConfirm.prototype.events, {
|
||||
"click .o_hr_attendance_punch_type": _.debounce(function(e) {
|
||||
var work_entry_type = $(e.target).data('work-entry-type');
|
||||
this.update_attendance(work_entry_type);
|
||||
}, 200, true),
|
||||
"click .o_hr_attendance_pin_pad_button_work": _.debounce(function(e) {
|
||||
var work_entry_type = $(e.target).data('work-entry-type');
|
||||
this.update_attendance_pin(work_entry_type);
|
||||
}, 200, true),
|
||||
}),
|
||||
willStart: function () {
|
||||
var self = this;
|
||||
|
||||
var def = this._rpc({
|
||||
model: 'hr.attendance',
|
||||
method: 'gather_attendance_work_types',
|
||||
args: []})
|
||||
.then(function (res) {
|
||||
self.work_types = res;
|
||||
});
|
||||
|
||||
return Promise.all([def, this._super.apply(this, arguments)]);
|
||||
},
|
||||
update_attendance: function (type) {
|
||||
var self = this;
|
||||
this._rpc({
|
||||
model: 'hr.employee',
|
||||
method: 'attendance_manual',
|
||||
args: [[self.employee_id], this.next_action, false, type],
|
||||
})
|
||||
.then(function(result) {
|
||||
if (result.action) {
|
||||
self.do_action(result.action);
|
||||
} else if (result.warning) {
|
||||
self.do_warn(result.warning);
|
||||
}
|
||||
});
|
||||
},
|
||||
update_attendance_pin: function (type) {
|
||||
var self = this;
|
||||
this.$('.o_hr_attendance_pin_pad_button_ok').attr("disabled", "disabled");
|
||||
this.$('.o_hr_attendance_pin_pad_button_work').attr("disabled", "disabled");
|
||||
this._rpc({
|
||||
model: 'hr.employee',
|
||||
method: 'attendance_manual',
|
||||
args: [[this.employee_id], this.next_action, this.$('.o_hr_attendance_PINbox').val(), type],
|
||||
})
|
||||
.then(function(result) {
|
||||
if (result.action) {
|
||||
self.do_action(result.action);
|
||||
} else if (result.warning) {
|
||||
self.do_warn(result.warning);
|
||||
self.$('.o_hr_attendance_PINbox').val('');
|
||||
setTimeout( function() {
|
||||
self.$('.o_hr_attendance_pin_pad_button_ok').removeAttr("disabled");
|
||||
self.$('.o_hr_attendance_pin_pad_button_work').removeAttr("disabled");
|
||||
}, 500);
|
||||
}
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
core.action_registry.add('hr_attendance_kiosk_confirm', KioskConfirmTyped);
|
||||
return KioskConfirmTyped;
|
||||
});
|
||||
50
hr_attendance_work_entry/static/src/js/my_attendances.js
Normal file
50
hr_attendance_work_entry/static/src/js/my_attendances.js
Normal file
@@ -0,0 +1,50 @@
|
||||
odoo.define('hr_attendance_work_entry.my_attendances', function (require) {
|
||||
"use strict";
|
||||
|
||||
var core = require('web.core');
|
||||
var MyAttendances = require('hr_attendance.my_attendances');
|
||||
|
||||
var MyTypedAttendances = MyAttendances.extend({
|
||||
events: _.extend({}, MyAttendances.prototype.events, {
|
||||
"click .o_hr_attendance_punch_type": _.debounce(function(e) {
|
||||
var work_entry_type = $(e.target).data('work-entry-type');
|
||||
this.update_attendance(work_entry_type);
|
||||
}, 200, true),
|
||||
}),
|
||||
|
||||
willStart: function () {
|
||||
var self = this;
|
||||
|
||||
var def = this._rpc({
|
||||
model: 'hr.attendance',
|
||||
method: 'gather_attendance_work_types',
|
||||
args: []})
|
||||
.then(function (res) {
|
||||
self.work_types = res;
|
||||
});
|
||||
|
||||
return Promise.all([def, this._super.apply(this, arguments)]);
|
||||
},
|
||||
|
||||
update_attendance: function (type) {
|
||||
var self = this;
|
||||
this._rpc({
|
||||
model: 'hr.employee',
|
||||
method: 'attendance_manual',
|
||||
args: [[self.employee.id], 'hr_attendance.hr_attendance_action_my_attendances', false, type],
|
||||
})
|
||||
.then(function(result) {
|
||||
if (result.action) {
|
||||
self.do_action(result.action);
|
||||
} else if (result.warning) {
|
||||
self.do_warn(result.warning);
|
||||
}
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
core.action_registry.add('hr_attendance_my_attendances', MyTypedAttendances);
|
||||
|
||||
return MyTypedAttendances;
|
||||
|
||||
});
|
||||
Reference in New Issue
Block a user