From 49d4ddd422145beee6d7bf442df9ecd0485d723d Mon Sep 17 00:00:00 2001 From: Joren Van Onder Date: Tue, 26 May 2015 15:52:44 +0200 Subject: [IMP] barcode_events: implement a new way of dealing with barcode events Implement a new way of dealing with barcode events. This was necessary because the old way of dealing with input coming from barcode devices did not stop keyevents. This lead to all kinds of issues (eg. barcode reader output being inserted as tender in a paymentline). This new class inserts itself so that it handles all keyevents before everything else. This means that it has authority on what keypress events pass and which ones do not. It differentiates between 'real' keyboard input and input coming from devices by buffering events. When a certain amount of events come in fast enough, it is handled as a barcode and a 'barcode_scanned' event is emitted on core.bus. When buffered events are decided to not be a barcode, they are recreated and redispatched. --- addons/web/static/src/js/web_client.js | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'addons/web/static/src/js/web_client.js') diff --git a/addons/web/static/src/js/web_client.js b/addons/web/static/src/js/web_client.js index de649d77aa2..dbd1e562810 100644 --- a/addons/web/static/src/js/web_client.js +++ b/addons/web/static/src/js/web_client.js @@ -14,6 +14,7 @@ var SystrayMenu = require('web.SystrayMenu'); var UserMenu = require('web.UserMenu'); var utils = require('web.utils'); var Widget = require('web.Widget'); +var BarcodeEvents = require('web.BarcodeEvents'); var QWeb = core.qweb; var _t = core._t; @@ -36,6 +37,7 @@ var WebClient = Widget.extend({ this.menu_dm = new utils.DropMisordered(); this.action_mutex = new utils.Mutex(); this.set('title_part', {"zopenerp": "Odoo"}); + this.barcode_events = new BarcodeEvents(); }, start: function() { var self = this; @@ -339,6 +341,9 @@ var WebClient = Widget.extend({ this.$('.oe_webclient').toggleClass( 'oe_content_full_screen', fullscreen); }, + get_barcode_events: function() { + return this.barcode_events; + } }); return WebClient; -- cgit v1.2.3