[FIX] barcodes: fix FieldFloatScannable on firefox
On firefox pressing special keys such as: Left Arrow or Backspace trigger a keypress event. This is different from google chrome which only generate a keydown and keyup event. There was thus two issue when using a FieldFloatScannable and firefox: 1. Keys such as ArrowLeft: would still be catched by FieldFloatScannable and be added programatically to the field but since Odoo didn't fix them a ASCII NUL character (0x0) would be added (in firefox it is represented by a large space). 2. Keys such as Backspace: would still be catched by FieldFloatScannable but were modified and corrected by Odoo so the corresponding ASCII character was added (ASCII BS character (0x8) for backspace). The feature in FieldFloatScannable which add the character is used to add characters for which the browser had been prevented to display them. Thus this fix: - for issue 1 and 2: only use the feature of FieldFloatScannable if the event was previously prevented and the current one is a forgery. - for issue 2: add "Backspace" and "Delete" as specials characters which should not be modified or stopped by the scanner heuristic. opw-706352
This commit is contained in:
@@ -113,6 +113,7 @@ var BarcodeEvents = core.Class.extend(mixins.PropertiesMixin, {
|
||||
if (e.key === "ArrowLeft" || e.key === "ArrowRight" ||
|
||||
e.key === "ArrowUp" || e.key === "ArrowDown" ||
|
||||
e.key === "Escape" || e.key === "Tab" ||
|
||||
e.key === "Backspace" || e.key === "Delete" ||
|
||||
/F\d\d?/.test(e.key)) {
|
||||
return true;
|
||||
} else {
|
||||
|
||||
@@ -23,6 +23,10 @@ var FieldFloatScannable = form_widgets.FieldFloat.extend({
|
||||
},
|
||||
|
||||
simulateKeypress: function (e) {
|
||||
/* only simulate a keypress if it has been previously prevented */
|
||||
if (e.originalEvent.dispatched_by_barcode_reader !== true) {
|
||||
return;
|
||||
}
|
||||
var character = String.fromCharCode(e.which);
|
||||
var current_str = e.target.value;
|
||||
var str_before_carret = current_str.substring(0, e.target.selectionStart);
|
||||
|
||||
Reference in New Issue
Block a user