Merge pull request #20458 from Easya-Solutions/fix-takepos-barcode-rule-qty

FIX search bracode rule and avoid undefined quantity on search in tak…
This commit is contained in:
Laurent Destailleur 2022-03-25 14:55:06 +01:00 committed by GitHub
commit 8f5b68bf3a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 2 deletions

View File

@ -142,7 +142,7 @@ if ($action == 'getProducts') {
}
if (isset($barcode_value_list['ref'])) {
//search product from reference
// search product from reference
$sql = "SELECT rowid, ref, label, tosell, tobuy, barcode, price";
$sql .= " FROM " . $db->prefix() . "product as p";
$sql .= " WHERE entity IN (" . getEntity('product') . ")";
@ -151,6 +151,7 @@ if ($action == 'getProducts') {
$sql .= " AND EXISTS (SELECT cp.fk_product FROM " . $db->prefix() . "categorie_product as cp WHERE cp.fk_product = p.rowid AND cp.fk_categorie IN (".$db->sanitize($filteroncategids)."))";
}
$sql .= " AND tosell = 1";
$sql .= " AND (barcode IS NULL OR barcode != '" . $db->escape($term) . "')";
$resql = $db->query($sql);
if ($resql && $db->num_rows($resql) == 1) {
@ -263,6 +264,7 @@ if ($action == 'getProducts') {
'price' => $obj->price,
'object' => 'product',
'img' => $ig,
'qty' => 1,
//'price_formated' => price(price2num($obj->price, 'MU'), 1, $langs, 1, -1, -1, $conf->currency)
);
}

View File

@ -620,7 +620,7 @@ function Search2(keyCodeForEnter) {
ChangeThirdparty(data[0]['rowid']);
}
else if ('product' == data[0]['object']) {
console.log("There is only 1 answer with barcode matching the search, so we add the product in basket");
console.log("There is only 1 answer matching the search, so we add the product in basket, qty="+data[0]['qty']);
ClickProduct(0, data[0]['qty']);
}
}