From 5b3267efb11638830cda275d95b0e8d3e521abb0 Mon Sep 17 00:00:00 2001 From: ufaks Date: Thu, 28 Jan 2016 17:04:25 +0500 Subject: [PATCH] fix bugs --- pos_keyboard/README.rst | 2 ++ pos_keyboard/__openerp__.py | 5 +++-- pos_keyboard/doc/changelog.rst | 9 +++++++++ pos_keyboard/static/src/js/pos.js | 24 ++++++++++++------------ 4 files changed, 26 insertions(+), 14 deletions(-) create mode 100644 pos_keyboard/doc/changelog.rst diff --git a/pos_keyboard/README.rst b/pos_keyboard/README.rst index 5c3b4b6..877d3ca 100644 --- a/pos_keyboard/README.rst +++ b/pos_keyboard/README.rst @@ -4,6 +4,8 @@ Module allows to use usual keyboard (not virtual one) in Point of Sale. Usage: ------ +Using keys below switch to mode you need. Qty mode is used by default. +Then use number keys to enter quantity, price or discount. =========== ===================== ================= diff --git a/pos_keyboard/__openerp__.py b/pos_keyboard/__openerp__.py index ab27142..52e5451 100644 --- a/pos_keyboard/__openerp__.py +++ b/pos_keyboard/__openerp__.py @@ -2,9 +2,10 @@ { 'name': "Keyboard support in Point Of Sale", 'author': "IT-Projects LLC, Ivan Yelizariev", - "website" : "https://yelizariev.github.io", + 'summary': 'Module allows to use usual keyboard (not virtual one) in Point of Sale', + "website": "https://yelizariev.github.io", 'images': ['images/keyboard.png'], - 'category' : 'Point Of Sale', + 'category': 'Point Of Sale', 'version': '1.0.0', 'depends': ['point_of_sale'], 'data': [ diff --git a/pos_keyboard/doc/changelog.rst b/pos_keyboard/doc/changelog.rst new file mode 100644 index 0000000..d2635e3 --- /dev/null +++ b/pos_keyboard/doc/changelog.rst @@ -0,0 +1,9 @@ +.. _changelog: + +Changelog +========= + +`1.0.1` +------- + +- Fix barcode scanner bug diff --git a/pos_keyboard/static/src/js/pos.js b/pos_keyboard/static/src/js/pos.js index 3561fe6..626e5a9 100644 --- a/pos_keyboard/static/src/js/pos.js +++ b/pos_keyboard/static/src/js/pos.js @@ -7,7 +7,7 @@ function pos_keyboard_widgets(instance, module){ res = resSuper.done(function(e){ self.pos.keypad.connect(); self.pos.keypad.set_action_callback(function(data){ - self.keypad_action(data, self.pos.keypad.type); + self.keypad_action(data, self.pos.keypad.type); }); }); return res; @@ -41,15 +41,15 @@ function pos_keyboard_widgets(instance, module){ }, }); - // this module mimics a keypad-only cash register. Use connect() and + // this module mimics a keypad-only cash register. Use connect() and // disconnect() to activate and deactivate it. module.Keypad = instance.web.Class.extend({ init: function(attributes){ this.pos = attributes.pos; - this.pos_widget = this.pos.pos_widget; + this.pos_widget = this.pos.pos_widget; this.type = { numchar: 'number, dot', - bmode: 'qty, disc, price', + bmode: 'qty, disc, price', sign: '+, -', backspace: 'backspace' } @@ -78,7 +78,7 @@ function pos_keyboard_widgets(instance, module){ reset_action_callback: function(){ this.action_callback = undefined; }, - + // starts catching keyboard events and tries to interpret keystrokes, // calling the callback when needed. connect: function(){ @@ -94,7 +94,7 @@ function pos_keyboard_widgets(instance, module){ var KC_AMT_1 = 80; // KeyCode: Price (Keypad 'p') var KC_DISC_1 = 68; // KeyCode: Discount Percentage [0..100] (Keypad 'd') - var KC_BACKSPACE = 8; // KeyCode: Backspace (Keypad 'backspace') + var KC_BACKSPACE = 8; // KeyCode: Backspace (Keypad 'backspace') var kc_lookup = { 48: '0', 49: '1', 50: '2', 51: '3', 52: '4', 53: '5', 54: '6', 55: '7', 56: '8', 57: '9', @@ -135,26 +135,26 @@ function pos_keyboard_widgets(instance, module){ self.data.val = kc_lookup[token]; is_number = true; ok = true; - } + } else if (token == KC_PLU || token == KC_PLU_1) { self.data.type = type.sign; ok = true; - } + } else if (token == KC_QTY || token == KC_QTY_1) { self.data.type = type.bmode; self.data.val = buttonMode.qty; ok = true; - } + } else if (token == KC_AMT || token == KC_AMT_1) { self.data.type = type.bmode; self.data.val = buttonMode.price; ok = true; - } + } else if (token == KC_DISC || token == KC_DISC_1) { self.data.type = type.bmode; self.data.val = buttonMode.disc; ok = true; - } + } else if (token == KC_BACKSPACE) { self.data.type = type.backspace; ok = true; @@ -175,7 +175,7 @@ function pos_keyboard_widgets(instance, module){ }); }, - // stops catching keyboard events + // stops catching keyboard events disconnect: function(){ $('body').off('keyup', '') }