Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #15565 Enhanced behaviour to select product on customer/supplier order to be able to use barcode reader efficiently #15704

Closed
wants to merge 2 commits into from

Conversation

zuiko
Copy link
Contributor

@zuiko zuiko commented Dec 8, 2020

Fix #15565 Enhanced behaviour to select product on customer/supplier order to be able to use barcode reader efficiently

This pull request is a transfer from a PR first issued on V12.0.3 under the reference #15694

When using a barcode reader in ajax list on customer/supplier order 2 conditions are necessary:

  1. The unique product found (it is allways unique, when exists, with a barcode reader) must be automatically selected,

  2. 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

  1. in file /core/class/html.form.class.php the change consists on setting 1 instead of 0
    $out .= ajax_autocompleter($selected, $htmlname, DOL_URL_ROOT.'/product/ajax/products.php', $urloption, $conf->global->PRODUIT_USE_SEARCH_TO_SELECT, 1, $ajaxoptions);

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.

  1. 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 passed by ajax_autocompleter function to limit disabling the ENTER key only for product selection in customer or supplier order function.
These precautions should be taken and validated by developers having a deeper knowledge than me about Dolibarr.

From PR Dolibarr#15565
At first suggested change by frederic34 on French Forum
In order to enhanced behaviour to select product on customer/supplier order to be able to use barcode reader efficiently,
a part of the job is that the product must be automatically selected if it is unique and it's allways searching product with barcode reader if this product exists.
I did not find any disadvantage in case of manual entry of the product reference.
To complete this enhencement, another change is necessary on /core/lib/ajax.lib.php in function ajax_autocompleter.
From PR Dolibarr#15565
In order to enhance behaviour to select product on customer/supplier order to be able to use barcode reader efficiently.
If /core/class/html.form.class.php has been changed in order to have the unique product automatically selected (by barcode reader),
we need to disable the ENTER (CR/LF) key eventually and most often sent by the barcode reader in order the selection not be erased by this too early ENTER (CR/LF).
Indeed, if not, the CR/LF is sent before the selection is effective.
@@ -68,6 +68,7 @@ function ajax_autocompleter($selected, $htmlname, $url, $urloption = '', $minLen
$("input#search_'.$htmlname.'").keydown(function(e) {
if (e.keyCode != 9) /* If not "Tab" key */
{
if (e.keyCode == 13) {return false;} /*disable "ENTER" key useful for barcode readers*/
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems ok.
However, i don't understand why changing parameter 0 to 1 into ajax_autocompleter
The goal of this parameter is to have field automatically filled when in the database, there is only 1 product. (in such a case, having a combo is useless).
So i merged manually this change only. Please check if it's ok.

Copy link
Contributor Author

@zuiko zuiko Dec 8, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi eldy,
In fact with 0, the combo remains... I just tested it.
If you don't change the parameter 0 to 1 into ajax_autocompleter the input is slower if the product is unique (by hand as with a barcode reader). Indeed, the input line remains filled with the barcode and ajax displays below the product to be selected. You have to click with the mouse or tap the down arrow on the keyboard to replace the barcode with the product code.
If the parameter is at 1, as soon as the barcode is complete, it is replaced on the same line by the product code, no further action is necessary. The speed is better.
When you do a lot during the day this small difference in ergonomics can be felt.

but my users gave me this testimony: the value 1 for select is relevant for entering customer orders with a barcode reader, but it is less relevant for entering supplier orders (which are not usually entered by hand shower), because the combo gives verification information which then disappears.This is especially true for the purchase price, which is not pre-filled in the box (is this voluntary?).

So on my side, I would keep select = 1 for customer orders and select = 0 for supplier orders.

@eldy eldy closed this in c26efd7 Dec 8, 2020
@zuiko
Copy link
Contributor Author

zuiko commented Dec 8, 2020

I don't know if it's better to answer here or not, so I copy my preceeding answer here:
Hi eldy,
In fact with 0, the combo remains... I just tested it.
If you don't change the parameter 0 to 1 into ajax_autocompleter the input is slower if the product is unique (by hand as with a barcode reader). Indeed, the input line remains filled with the barcode and ajax displays below the product to be selected. You have to click with the mouse or tap the down arrow on the keyboard to replace the barcode with the product code.
If the parameter is at 1, as soon as the barcode is complete, it is replaced on the same line by the product code, no further action is necessary. The speed is better.
When you do a lot during the day this small difference in ergonomics can be felt.

but my users gave me this testimony: the value 1 for select is relevant for entering customer orders with a barcode reader, but it is less relevant for entering supplier orders (which are not usually entered by hand shower), because the combo gives verification information which then disappears.This is especially true for the purchase price, which is not pre-filled in the box (is this voluntary?).

So on my side, I would keep select = 1 for customer orders and select = 0 for supplier orders.

Some screenshots:
select = 0
image
select=1
image

@zuiko
Copy link
Contributor Author

zuiko commented Dec 9, 2020

So I close here my branch and will renew some of my change soon...

@zuiko zuiko deleted the patch-2 branch December 9, 2020 19:53
zuiko added a commit to zuiko/dolibarr that referenced this pull request Dec 9, 2020
Complete the Fix to Dolibarr#15565 Enhanced behaviour to select product on customer/supplier order to be able to use barcode reader efficiently.
Answer to Eldy, Dolibarr#15704 (comment)
In fact the change alone to htdocs/core/lib/ajax.lib.php  is not, for me, sufficient to fix the issue.
if $conf->global->PRODUIT_USE_SEARCH_TO_SELECT, 0, the combo remains even if the product is alone.
So I recommend that the code is $conf->global->PRODUIT_USE_SEARCH_TO_SELECT, 1, (wihout combo) for product selection only for customer order filling because for this usage the the probability is higher to use a barcode scanner.
It is less relevant for filling supplier orders (which are not usually entered by barcode scanner), because the combo gives verification information which then disappears. (This is especially true for the purchase price, which is not pre-filled in the box for the moment I tested(?).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Enhanced behaviour to select product on customer/supplier order to be able to use barcode reader efficiently
2 participants