Browse Source

fix bugs

pull/155/head
ufaks 9 years ago
committed by Vincent Van Rossem
parent
commit
5b3267efb1
  1. 2
      pos_keyboard/README.rst
  2. 5
      pos_keyboard/__openerp__.py
  3. 9
      pos_keyboard/doc/changelog.rst
  4. 24
      pos_keyboard/static/src/js/pos.js

2
pos_keyboard/README.rst

@ -4,6 +4,8 @@ Module allows to use usual keyboard (not virtual one) in Point of Sale.
Usage: 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.
=========== ===================== ================= =========== ===================== =================

5
pos_keyboard/__openerp__.py

@ -2,9 +2,10 @@
{ {
'name': "Keyboard support in Point Of Sale", 'name': "Keyboard support in Point Of Sale",
'author': "IT-Projects LLC, Ivan Yelizariev", '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'], 'images': ['images/keyboard.png'],
'category' : 'Point Of Sale',
'category': 'Point Of Sale',
'version': '1.0.0', 'version': '1.0.0',
'depends': ['point_of_sale'], 'depends': ['point_of_sale'],
'data': [ 'data': [

9
pos_keyboard/doc/changelog.rst

@ -0,0 +1,9 @@
.. _changelog:
Changelog
=========
`1.0.1`
-------
- Fix barcode scanner bug

24
pos_keyboard/static/src/js/pos.js

@ -7,7 +7,7 @@ function pos_keyboard_widgets(instance, module){
res = resSuper.done(function(e){ res = resSuper.done(function(e){
self.pos.keypad.connect(); self.pos.keypad.connect();
self.pos.keypad.set_action_callback(function(data){ 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; 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. // disconnect() to activate and deactivate it.
module.Keypad = instance.web.Class.extend({ module.Keypad = instance.web.Class.extend({
init: function(attributes){ init: function(attributes){
this.pos = attributes.pos; this.pos = attributes.pos;
this.pos_widget = this.pos.pos_widget;
this.pos_widget = this.pos.pos_widget;
this.type = { this.type = {
numchar: 'number, dot', numchar: 'number, dot',
bmode: 'qty, disc, price',
bmode: 'qty, disc, price',
sign: '+, -', sign: '+, -',
backspace: 'backspace' backspace: 'backspace'
} }
@ -78,7 +78,7 @@ function pos_keyboard_widgets(instance, module){
reset_action_callback: function(){ reset_action_callback: function(){
this.action_callback = undefined; this.action_callback = undefined;
}, },
// starts catching keyboard events and tries to interpret keystrokes, // starts catching keyboard events and tries to interpret keystrokes,
// calling the callback when needed. // calling the callback when needed.
connect: function(){ connect: function(){
@ -94,7 +94,7 @@ function pos_keyboard_widgets(instance, module){
var KC_AMT_1 = 80; // KeyCode: Price (Keypad 'p') var KC_AMT_1 = 80; // KeyCode: Price (Keypad 'p')
var KC_DISC_1 = 68; // KeyCode: Discount Percentage [0..100] (Keypad 'd') 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 = { var kc_lookup = {
48: '0', 49: '1', 50: '2', 51: '3', 52: '4', 48: '0', 49: '1', 50: '2', 51: '3', 52: '4',
53: '5', 54: '6', 55: '7', 56: '8', 57: '9', 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]; self.data.val = kc_lookup[token];
is_number = true; is_number = true;
ok = true; ok = true;
}
}
else if (token == KC_PLU || token == KC_PLU_1) { else if (token == KC_PLU || token == KC_PLU_1) {
self.data.type = type.sign; self.data.type = type.sign;
ok = true; ok = true;
}
}
else if (token == KC_QTY || token == KC_QTY_1) { else if (token == KC_QTY || token == KC_QTY_1) {
self.data.type = type.bmode; self.data.type = type.bmode;
self.data.val = buttonMode.qty; self.data.val = buttonMode.qty;
ok = true; ok = true;
}
}
else if (token == KC_AMT || token == KC_AMT_1) { else if (token == KC_AMT || token == KC_AMT_1) {
self.data.type = type.bmode; self.data.type = type.bmode;
self.data.val = buttonMode.price; self.data.val = buttonMode.price;
ok = true; ok = true;
}
}
else if (token == KC_DISC || token == KC_DISC_1) { else if (token == KC_DISC || token == KC_DISC_1) {
self.data.type = type.bmode; self.data.type = type.bmode;
self.data.val = buttonMode.disc; self.data.val = buttonMode.disc;
ok = true; ok = true;
}
}
else if (token == KC_BACKSPACE) { else if (token == KC_BACKSPACE) {
self.data.type = type.backspace; self.data.type = type.backspace;
ok = true; ok = true;
@ -175,7 +175,7 @@ function pos_keyboard_widgets(instance, module){
}); });
}, },
// stops catching keyboard events
// stops catching keyboard events
disconnect: function(){ disconnect: function(){
$('body').off('keyup', '') $('body').off('keyup', '')
} }

Loading…
Cancel
Save