Merge pull request #25227 from frederic34/patch-2

Fix cant do manual correct stock if reel is null in db
This commit is contained in:
Laurent Destailleur 2023-06-29 17:18:22 +02:00 committed by GitHub
commit 3bcdc54b0a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -540,7 +540,7 @@ class MouvementStock extends CommonObject
// Update stock quantity
if (!$error) {
if ($alreadyarecord > 0) {
$sql = "UPDATE ".$this->db->prefix()."product_stock SET reel = reel + ".((float) $qty);
$sql = "UPDATE ".$this->db->prefix()."product_stock SET reel = COALESCE(reel, 0) + ".((float) $qty);
$sql .= " WHERE fk_entrepot = ".((int) $entrepot_id)." AND fk_product = ".((int) $fk_product);
} else {
$sql = "INSERT INTO ".$this->db->prefix()."product_stock";