[FIX] hr_attendance: multiple scans
- Open the Attendance kiosk mode
- Scan an incorrect barcode
It's not possible to scan any barcode anymore.
If the barcode is incorrect, we need to add back the event listener.
Moreover, the RPC introduced with bbc7e9586d is not necessary if
we retrieve the barcode thanks to the existing RPC call.
opw-1878632
opw-1888402
closes odoo/odoo#28354
This commit is contained in:
@@ -90,6 +90,7 @@ class HrEmployee(models.Model):
|
||||
action_message = self.env.ref('hr_attendance.hr_attendance_action_greeting_message').read()[0]
|
||||
action_message['previous_attendance_change_date'] = self.last_attendance_id and (self.last_attendance_id.check_out or self.last_attendance_id.check_in) or False
|
||||
action_message['employee_name'] = self.name
|
||||
action_message['barcode'] = self.barcode
|
||||
action_message['next_action'] = next_action
|
||||
|
||||
if self.user_id:
|
||||
|
||||
@@ -51,22 +51,7 @@ var GreetingMessage = AbstractAction.extend({
|
||||
this.attendance.check_in_time = this.attendance.check_in && this.attendance.check_in.format(this.format_time);
|
||||
this.attendance.check_out_time = this.attendance.check_out && this.attendance.check_out.format(this.format_time);
|
||||
this.employee_name = action.employee_name;
|
||||
},
|
||||
|
||||
willStart: function() {
|
||||
var self = this;
|
||||
var def;
|
||||
if (this.attendance && this.attendance.employee_id) {
|
||||
def = this._rpc({
|
||||
model: 'hr.employee',
|
||||
method: 'read',
|
||||
args: [this.attendance.employee_id[0], ['barcode']],
|
||||
})
|
||||
.then(function (employee) {
|
||||
self.attendanceBarcode = employee[0].barcode;
|
||||
});
|
||||
}
|
||||
return $.when(this._super.apply(this, arguments), def);
|
||||
this.attendanceBarcode = action.barcode;
|
||||
},
|
||||
|
||||
start: function() {
|
||||
@@ -167,7 +152,10 @@ var GreetingMessage = AbstractAction.extend({
|
||||
self.do_action(result.action);
|
||||
} else if (result.warning) {
|
||||
self.do_warn(result.warning);
|
||||
setTimeout( function() { self.do_action(self.next_action, {clear_breadcrumbs: true}); }, 5000);
|
||||
}
|
||||
}, function () {
|
||||
setTimeout( function() { self.do_action(self.next_action, {clear_breadcrumbs: true}); }, 5000);
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
@@ -47,7 +47,10 @@ var KioskMode = AbstractAction.extend({
|
||||
self.do_action(result.action);
|
||||
} else if (result.warning) {
|
||||
self.do_warn(result.warning);
|
||||
core.bus.on('barcode_scanned', self, self._onBarcodeScanned);
|
||||
}
|
||||
}, function () {
|
||||
core.bus.on('barcode_scanned', self, self._onBarcodeScanned);
|
||||
});
|
||||
},
|
||||
|
||||
|
||||
@@ -120,6 +120,7 @@ QUnit.module('HR Attendance', {
|
||||
employee_id: [barcode],
|
||||
},
|
||||
next_action: "hr_attendance.hr_attendance_action_kiosk_mode",
|
||||
barcode: barcode,
|
||||
}
|
||||
var clientAction = new GreetingMessage(null, action);
|
||||
testUtils.addMockEnvironment(clientAction, {
|
||||
|
||||
Reference in New Issue
Block a user