summaryrefslogtreecommitdiff
path: root/addons/barcodes/static/src/js/barcode_events.js
AgeCommit message (Collapse)Author
2020-09-07[FIX] *: typos and english incoherencesVictor Feyens
Mainly transifex issues but also some errors found through 'grep' checks. Fix typos and obscure english strings in xml contents, fields strings/helps, some docstrings, ... ensuring correct translations base (and fallback when translations isn't available). closes odoo/odoo#57206 Related: odoo/enterprise#13032 Signed-off-by: Martin Trigaux (mat) <mat@odoo.com>
2020-02-21[FIX] barcode: input text is visibleRomeo Fragomeli
Before this commit, in mobile, the input to handle the input event of scanner was visible but with a negative z-index to be in the back of Odoo viewport. After this commit, in mobile, the input is transparent (opacity 0) and so is not visible anymore but it's still present. Steps to reproduce: * Go to app switcher (in mobile) * Scan a barcode with a hardware scanner BUG closes odoo/odoo#45975 X-original-commit: b2b1e68e541966ad832e03fbc230418d14c85616 Signed-off-by: Adrien Dieudonné (adr) <adr@odoo.com>
2019-10-18[REF] web,barcodes: simplify mobile device detectionRomeo Fragomeli
In this commit, we introduce "isMobileDevice". Do not confuse with isMobile. isMobile: A frequent use case is to have a different render in 'mobile' mode, meaning when the screen is small. This flag (boolean) is true when the size is XS/VSM/SM. It is also updated dynamically. isMobileDevice: Mobile device detection using userAgent. This flag doesn't depend on the size/resolution of the screen. It targets mobile devices which suggests that there is a virtual keyboard. Task ID: 2090202
2019-10-02[FIX] barcodes: Whitelist search inputsJairo Llopis
Before this patch, on mobile chrome, if user had focused in a `<input type=search>` element and writes something, the value never lands in the target input element and the on-screen keyboard hides. closes odoo/odoo#37843 X-original-commit: 12d4040b7196ae8f7a27d0081638413b52340019 Signed-off-by: Nicolas Martinelli (nim) <nim@odoo.com>
2019-03-25[MERGE] forward port branch saas-12.2 up to 230ad8c381eChristophe Simonis
closes odoo/odoo#32088 Signed-off-by: Christophe Simonis <chs@odoo.com>
2019-03-18[FIX] barcodes: let focus in number, password, tel, phone inputsAdrien Dieudonne
Before this commit, users wasn't able to input values in some input elements like password, email and phone in mobile. Steps to reproduce: - Go to user - Select Preferences - Select Change password - Try to input something => The focus was lost and the keyboard disappeared In fact, a hidden input always have the focus when no other fields need it. This input is used to intercept a value from a barcode scanner. So now, we added some input types to avoid to set the focus on the barcode input. The barcode input is now always defined (even if not used in desktop) to be able to mock a Chrome mobile environment in a test. opw-1936712 opw-1948266 closes odoo/odoo#31841 Signed-off-by: Pierre Paridans <pparidans@users.noreply.github.com>
2019-03-13Revert "[FIX] barcodes: let focus in number, password, tel, phone inputs"Adrien Dieudonne
This reverts commit 1cdf2bdaf6fb8de398384b04287e564bfcd063ec. $(':focus') seems not working depending on browser version but we don't know yet exactly why. opw-1948266 closes odoo/odoo#31807 Signed-off-by: Christophe Monniez (moc) <moc@odoo.com>
2019-03-06[REF] barcodes: adapt code after jQuery updateVincent Schippefilt
Part of task 1896658 Co-authored-by: Aaron Bohy <aab@odoo.com> Co-authored-by: Christophe Matthieu <chm@odoo.com> Co-authored-by: Mathieu Duckerts-Antoine <dam@odoo.com> Co-authored-by: David Monjoie <dmo@odoo.com> Co-authored-by: Martin Geubelle <mge@odoo.com> Co-authored-by: svs-odoo <svs@odoo.com> Co-authored-by: Vincent Schippefilt <vsc@odoo.com>
2019-03-11[FIX] barcodes: let focus in number, password, tel, phone inputsAdrien Dieudonne
Before this commit, users wasn't able to input values in some input elements like password, email and phone in mobile. Steps to reproduce: - Go to user - Select Preferences - Select Change password - Try to input something => The focus was lost and the keyboard disappeared In fact, a hidden input always have the focus when no other fields need it. This input is used to intercept a value from a barcode scanner. So now, we added some input types to avoid to set the focus on the barcode input. It's quite difficult to test this feature because we aren't allow to simultate a keyboard to write in a input field. See https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent Plus, we don't have the focus in mobile except if we have the cursor inside the window. So, we can't test focused elements or input values. opw-1936712 opw-1948266 closes odoo/odoo#31566 Signed-off-by: Pierre Paridans <pparidans@users.noreply.github.com>
2018-09-11[FIX] barcodes: don't listen to barcode in input numberSimon Lejeune
related to rev 74fcd3ac3b0445c5fc0d9239900a9a41bfd04de8
2018-08-08[MERGE] forward port branch saas-15 up to e7ccf38c48bChristophe Simonis
2018-08-08[FIX] barcodes: ok PageUp/Down/Home/End in firefoxNicolas Lempereur
Same reason as 8d948d92. In firefox if barcode is installed, for example on a form view the keys to navigate the possible scrolling PageUp/PageDown/Home/End don't work at all. This is caused by the interface barcode catching and differences of the key event handling between firefox and other browser. So in this change, we add these keys so they are not catched by barcode. note: aso backport 5bc29744c so the code is the same between 10 and 11. related to opw-706352 closes #26219
2018-05-30[FIX] barcodes: avoid virtual keyboard to show up while scanning barcodeAdrien Dieudonne
(1) Before this commit, the input barcode was removed from the dom after each scan but now we want to keep it focused to avoid to automatically open the virtual keyboard in mobile. This behavior will be useful in enterprise only. Another commit will follow in this repository. As the input is not removed anymore, we had to disable autocomplete to hide previous entries as suggestions. (2) We also add z-index property to avoid to click on the hidden input located in the middle of the page.
2018-04-30[FIX] barcodes: Android Odoo app webview not detected as chromeAdrien Dieudonne
Before this commit, it wasn't possible to use a barcode scanner with the Odoo mobile app. However it works fine for mobile Chrome browsers. We now know that 'keypress' event doesn't work as expected in Chrome for mobile. See @3a74afd21 It's why 'keydown' detection has been implemented. We also want to use this detection in our Android app. Unfortunately, 'window.chrome' doesn't seem to exist anymore in the Android webview. In this commit, we change the way Chrome is detected.
2018-04-30[FIX] barcodes: keep vertical position while scanningAdrien Dieudonne
Before this commit, you were automatically redirected to the top of the page when you scanned a product. It was, therefore, difficult to find the product that had just been scanned and to check its quantity. Because of @3a74afd21 we need to put the focus in an invisible input at the top of the page. This input is now always vertically centered in the middle of the page.
2018-03-20[FIX] barcodes: barcode scanning on Chrome mobileAdrien Dieudonne
Before this commit, the barcode value wasn't triggered on some Android devices with Google Chrome and using the Odoo app. In fact, the keypress event may not trigger with some devices. This is probably due to the fact that this event is marked as 'Legacy'. See: https://www.w3.org/TR/uievents/#legacy-keyboardevent-event-types To fix this, we can use 'keydown' event but we have to handle an other issue: there is no way to know which key is typed. The auto-suggest feature on Android invalidate all the following properties: Keycode, charCode, key, which, keyIdentifier, code. This is a well-known issue: https://bugs.chromium.org/p/chromium/issues/detail?id=118639 For more infos, please read this blog: https://www.outsystems.com/blog/javascript-events-unmasked-how-to-create-input-mask-for-mobile.html As a work around, we create a temporary input field that stores the barcode value. The focus is set on this input when a keydown is detected. Note that when an input has the focus, the android virtual keyboard will be opened. We can't avoid this behavior. The only thing we can do is to automatically close it after 800 ms. See: https://bugs.chromium.org/p/chromium/issues/detail?id=662386 As this fix is specific for Chrome only, it's not possible to test it easily. Some tests will be added in master.
2018-03-20[FIX] barcodes: skip undefined keys in barcode valueAdrien Dieudonne
This fixes an issue occurring with Firefox. Some events was buffered with an undefined value and it wasn't possible to build the barcode value from these events. See 'handle_buffered_keys' function. So now, we simply skip this kind of event. We consider this as 'special keys'.
2018-02-01[MERGE] forward port branch saas-16 up to 920aa6174c9Christophe Simonis
2018-02-01[MERGE] forward port branch saas-15 up to e0422bfd6c5Christophe Simonis
2018-01-31[FIX] barcodes: delay between keysNicolas Martinelli
In order to detect if a barcode scanner is being used, we detect the delay between keypresses. The value is hardcoded to 55 ms. However, in the case of a bluetooth scanner, this delay is often not enough, resulting in an incorrect capture of the barcode. We add the config parameter `barcode.max_time_between_keys_in_ms` which allows the user to fine tune this delay for his hardware. opw-806398
2017-09-18[FIX] *: fix a bunch of incorrectly documented docstringXavier Morel
Fix a bunch of ill-documented/incomplete/incorrect method docs Without this, the automatic doc generation does not work.
2017-08-25[FIX] barcodes: fix several issues when scanning barcodesAkash Bhavsar
Since the new views, most of the barcodes feature was broken. This commit re-enables the support of commands like 'edit', 'save', 'cancel', 'previous' and 'next'. Also changed javascript event handler to jquery event handler to make barcodes testable in phantomjs.
2017-04-11[REF] barcode, *: update code to new JS frameworkChristophe Matthieu
With the new views, the barcode mechanisms were completely broken, because the view and widget JS code was totally changed. This commit update and refactor all that code to make it work with the new design philosophy. Also, it update the coding style.
2017-04-11[REF] *: remove mixins from web.coreGéry Debongnie
It is better to directly import web.mixins
2017-03-24[FIX] barcodes: fix FieldFloatScannable on firefoxNicolas Lempereur
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
2016-12-07[FIX] barcodes: compatibility of `new Event()` for IE >= 9.0Denis Ledoux
Using the constructor `new Event()` is not supported in IE >= 9.0 (tested on IE 11). It raises the below error: `Object doesn't support this action` This revision implements the Polyfill `CustomEvent()` suggested by the MDN here: https://developer.mozilla.org/en-US/docs/Web/API/CustomEvent/CustomEvent and uses it if the `new Event()` call fails. opw-690984
2016-07-13[FIX] barcodes: allow users to 'click' focused buttons with ReturnJoren Van Onder
Return key events don't get redispatched and even if they did, it wouldn't work because 'fake' keypress events don't trigger native HTML event handlers. This should be safe because Return cannot start a valid barcode.
2016-06-15[FIX] barcodes: manage several barcode widgetsNicolas Martinelli
In some cases, several barcode widgets can be found on the same page. This is for example the case of the stock picking: there is a widget on the `stock.picking` model (main view) itself, and a widget on the `stock.pack.operation` model (modal view). In this case, when the focus is not set directly on the field which needs to be filled in, both widgets will trigger a `barcode_scanned` scanned event. This will call the `on_barcode_scanned` Python method which can lead to errors/warning. For example, the `on_barcode_scanned` method on the `stock.picking` model raises a warning in case the barcode scanned does not match any product/package. The fix is to make sure that the event target is located in the correct DOM element. opw-677506
2015-09-15[FIX] barcodes: don't require suffix for scansArthur Maniet
Users don't have to configure their scanner. As stated in the docs/planner, either wait 50ms between 2 scans or use a suffix.
2015-09-03[IMP] barcodes: BarcodeEvents uses reserved barcodes prefixesArthur Maniet
Export a list of barcodes prefixes used for software functionss
2015-09-01[FIX] barcodes: use _.bind instead of function.bind because IEArthur Maniet
2015-08-05[FIX] barcodes: key repeat prevention was mistakenly activatedArthur Maniet
TIL: The $(callback) function passes the jquery object to the callback
2015-07-30[FIX/REF] barcodes: don't catch keypress if a control key is pressedArthur Maniet
This avoids breaking shortcuts on Firefox, which rely on keypress events instead of keydown / keyup. The tradeoff is that a barcode cannot be scanned and interpreted if ctrl, alt or cmd is pressed. Also don't catch function keys.
2015-07-30[FIX] barcodes: styleArthur Maniet
2015-07-30[IMP] barcodes: use a regexp to match a barcodeArthur Maniet
2015-07-30[IMP] barcodes: use a known terminal char to stops buffering keysArthur Maniet
BarcodeEvents uses the fact that a barcode usually ends with \n, \r or \t - and never contains it - to stop buffing keys as soon as such a character is inputted instead of waiting x milliseconds.
2015-07-30[REF] barcodes: make key repeat prevention optionalArthur Maniet
This functionality was an attemps to fix the chair-to-keyboard interface in the PoS. Since it is not a standard behaviour, it must be explicitly requested.
2015-07-30[FIX] barcodes: BarcodeEvents handler binding and unbindingArthur Maniet
In order to remove an eventhandler, removeEventListener must receive the same function reference that was passed to addEventListener. So the handlers references are kept as attributes of the class.
2015-07-30[REF] web: move barcode_events to module barcodesArthur Maniet
If the module barcodes is installed, a BarcodeEvents singleton is automatically instanciated. It listens to keypresses and, when a sequence of keys represents a barcode, it broadcasts a 'barcode_scanned' event on core.bus containing the barcode string.