diff --git a/addons/hr_attendance/static/src/js/greeting_message.js b/addons/hr_attendance/static/src/js/greeting_message.js index a97564ae563..57191d0965b 100644 --- a/addons/hr_attendance/static/src/js/greeting_message.js +++ b/addons/hr_attendance/static/src/js/greeting_message.js @@ -5,6 +5,7 @@ var AbstractAction = require('web.AbstractAction'); var core = require('web.core'); var _t = core._t; +var previously_barcode_scanned; var GreetingMessage = AbstractAction.extend({ @@ -53,6 +54,20 @@ var GreetingMessage = AbstractAction.extend({ this.employee_name = action.employee_name; }, + willStart: function() { + if (this.attendance != undefined){ + this._rpc({ + model: 'hr.employee', + method: 'read', + args: [this.attendance.employee_id[0], ['barcode']], + }) + .then(function (employee) { + previously_barcode_scanned = employee[0].barcode; + }); + } + return this._super.apply(this, arguments); + }, + start: function() { if (this.attendance) { this.attendance.check_out ? this.farewell_message() : this.welcome_message(); @@ -139,18 +154,21 @@ var GreetingMessage = AbstractAction.extend({ if (this.return_to_main_menu) { // in case of multiple scans in the greeting message view, delete the timer, a new one will be created. clearTimeout(this.return_to_main_menu); } - this._rpc({ - model: 'hr.employee', - method: 'attendance_scan', - args: [barcode, ], - }) - .then(function (result) { - if (result.action) { - self.do_action(result.action); - } else if (result.warning) { - self.do_warn(result.warning); - } - }); + if (previously_barcode_scanned != barcode){ + previously_barcode_scanned = barcode; + this._rpc({ + model: 'hr.employee', + method: 'attendance_scan', + args: [barcode, ], + }) + .then(function (result) { + if (result.action) { + self.do_action(result.action); + } else if (result.warning) { + self.do_warn(result.warning); + } + }); + } }, destroy: function () { diff --git a/addons/hr_attendance/static/src/js/kiosk_mode.js b/addons/hr_attendance/static/src/js/kiosk_mode.js index 750fa43df47..361977717fe 100644 --- a/addons/hr_attendance/static/src/js/kiosk_mode.js +++ b/addons/hr_attendance/static/src/js/kiosk_mode.js @@ -36,6 +36,7 @@ var KioskMode = AbstractAction.extend({ _onBarcodeScanned: function(barcode) { var self = this; + core.bus.off('barcode_scanned', this, this._onBarcodeScanned); this._rpc({ model: 'hr.employee', method: 'attendance_scan', @@ -57,7 +58,6 @@ var KioskMode = AbstractAction.extend({ }, destroy: function () { - core.bus.off('barcode_scanned', this, this._onBarcodeScanned); clearInterval(this.clock_start); clearInterval(this._interval); this._super.apply(this, arguments);