This question has been flagged

In Odoo 10.0 (Enterprise) POS I currently cannot use the numpad comma on a german keyboard.

the keyboard_handler function in the init function for the PaymentScreenWidget is defined like this:

                } else if ( event.keyCode === 190 || // Dot
                            event.keyCode === 110 ||  // Decimal point (numpad)
                            event.keyCode === 188 ||  // Comma
                            event.keyCode === 46 ) {  // Numpad dot
                    key = self.decimal_point;

The keyCode for the (numpad) comma is 44 which is not handled by this. How would I go about changing this? I wrote a module which at first tried to extend the PaymentScreenWidget init function like this:

odoo.define('fd_pos_mod.screens', function (require) {
"use strict";
var screens = require('point_of_sale.screens');

screens.PaymentScreenWidget.extend({
init: function(parent, options) {
var self = this;
this._super(parent, options);

// This keyboard handler listens for keypress events. It is
// also called explicitly to handle some keydown events that
// do not generate keypress events.
this.keyboard_handler = function(event){
var key = '';

if (event.type === "keypress") {
if (event.keyCode === 13) { // Enter
self.validate_order();
} else if ( event.keyCode === 190 || // Dot
event.keyCode === 110 || // Decimal point (numpad)
event.keyCode === 188 || // Comma
event.keyCode === 46 || // Numpad dot
event.keyCode === 44) { // Numpad comma
key = self.decimal_point;
} else if (event.keyCode >= 48 && event.keyCode <= 57) { // Numbers
key = '' + (event.keyCode - 48);
} else if (event.keyCode === 45) { // Minus
key = '-';
} else if (event.keyCode === 43) { // Plus
key = '+';
}
} else { // keyup/keydown
if (event.keyCode === 46) { // Delete
key = 'CLEAR';
} else if (event.keyCode === 8) { // Backspace
key = 'BACKSPACE';
}
}

self.payment_input(key);
event.preventDefault();
};
},
});
});

I could see my .js being loaded but it didn't do anything. Then I tried overloading the prototype of PaymentScreenWidget like this:

odoo.define('fd_pos_mod.screens', function (require) {
"use strict";
var screens = require('point_of_sale.screens');

screens.PaymentScreenWidget.prototype.init = function(parent, options) {
init: function(parent, options) {
var self = this;
this._super(parent, options);

this.pos.bind('change:selectedOrder',function(){
this.renderElement();
this.watch_order_changes();
},this);
this.watch_order_changes();

this.inputbuffer = "";
this.firstinput = true;
this.decimal_point = _t.database.parameters.decimal_point;

// This is a keydown handler that prevents backspace from
// doing a back navigation. It also makes sure that keys that
// do not generate a keypress in Chrom{e,ium} (eg. delete,
// backspace, ...) get passed to the keypress handler.
this.keyboard_keydown_handler = function(event){
if (event.keyCode === 8 || event.keyCode === 46) { // Backspace and Delete
event.preventDefault();

// These do not generate keypress events in
// Chrom{e,ium}. Even if they did, we just called
// preventDefault which will cancel any keypress that
// would normally follow. So we call keyboard_handler
// explicitly with this keydown event.
self.keyboard_handler(event);
}
};

// This keyboard handler listens for keypress events. It is
// also called explicitly to handle some keydown events that
// do not generate keypress events.
this.keyboard_handler = function(event){
var key = '';

if (event.type === "keypress") {
if (event.keyCode === 13) { // Enter
self.validate_order();
} else if ( event.keyCode === 190 || // Dot
event.keyCode === 110 || // Decimal point (numpad)
event.keyCode === 188 || // Comma
event.keyCode === 46 || // Numpad dot
event.keyCode === 44) { // Numpad comma
key = self.decimal_point;
} else if (event.keyCode >= 48 && event.keyCode <= 57) { // Numbers
key = '' + (event.keyCode - 48);
} else if (event.keyCode === 45) { // Minus
key = '-';
} else if (event.keyCode === 43) { // Plus
key = '+';
}
} else { // keyup/keydown
if (event.keyCode === 46) { // Delete
key = 'CLEAR';
} else if (event.keyCode === 8) { // Backspace
key = 'BACKSPACE';
}
}

self.payment_input(key);
event.preventDefault();
};

this.pos.bind('change:selectedClient', function() {
self.customer_changed();
}, this);
},
};
});

Still no dice. Can anyone tell me what I'm doing wrong? Or better yet, tell me how to do it correctly? :)

Avatar
Discard