Fix #15565 Enhanced behaviour to select product on customer/supplier order to be able to use barcode reader efficiently #15694
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fix #15565 Enhanced behaviour to select product on customer/supplier order to be able to use barcode reader efficiently
Correction made and validated on sources V12.0.3.
See also Pull Request #15704 which is the same correction reported on the current branch (with no conflicts).
When using a barcode reader in ajax list on customer/supplier order 2 conditions are necessary:
The unique product found (it is allways unique, when exists, with a barcode reader) must be automatically selected,
The ENTER (CR/LF) key must be ignored if sent by the barcode reader (it's very often the case), because this ENTER key comes too early and erase the previous automatic typing before the ajax selection could be done.
If the data (from the Products module):
Wait until you have pressed a key before loading the contents of the product drop-down list.
is set to YES (1 to 3 characters),
the performance will be excellent (instantaneous for a test with more than 10K products).
The performance will be not worst if this data would be set to NO.
I did not see any inconvenience and interferences with manual typing after these changes.
For the point
in file /core/class/html.form.class.php the change consists on setting 1 instead of 0
print ajax_autocompleter($selected, $htmlname, DOL_URL_ROOT.’/product/ajax/products.php’, $urloption, $conf->global->PRODUIT_USE_SEARCH_TO_SELECT, 1, $ajaxoptions);
For the 2 instances customer order and supplier order.
in file /core/lib/ajax.lib.php in function ajax_autocompleter the change consists on
if (e.keyCode == 13) {return false;} /*disable "ENTER" key */
on characters reading for this task.
I don't know if there is interference with other functions by deactivating the ENTER key in this treatment.
If this is the case, a parameter setting might be necessary...
Or a new parameter to ajax_autocompleter function to limit disabling ENTER only for product selection in customer or supplier order.
I ask your indulgence for this first Pull Request in Dolibarr ;-)