Rational
Barcode and QR code are used to quickly input data. Tryton clients could benefit from supporting scanners to fill form quickly.
Proposal
A new attribute is added to the form
which contains the list of type of barcode or qr code to detect.
When set the client display an input entry and a button to start the reader or if no reader is supported just the entry (with a customizable shortcut to set the focus on it).
The position must be fixed to be always visible.
When the user starts the reader, the client display a feedback of the video in a popup until a code bar is detected. An option activate or not a beep to warn user that a code has been detected. And another defines if the reader must stop or keep scanning until the user close the window.
When a code is scanned (or entered and validated in the input), the client calls a method on_code_scan
which behaves like an instance button but with the code
as parameter (the depends
are managed like for the buttons).
The method could raise exceptions in case the code can not be processed (and if the option is activate, another beep is played).
To support hardware scanner (which behaves most of the time as a keyboard), the input shortcut can be used as trigger by the scanner to put the focus on the input before “typing” the code.
Dependencies
For the web client we can use the library quagga2, the main advantage against the common zxing is that it is invariant to scale and rotation.
And for the desktop client we can use zbar.
Usage
The feature can be activate on the Sale Point to find product to add (or to increase) with a quantity of 1 (if the sale unit has no digits).