From fe04dd02f5dcd9c697b2c239d1506aa3f8a1d901 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 24 Mar 2026 18:53:26 +0100 Subject: [PATCH] Fix set status of product with MAIN_DIRECT_STATUS_UPDATE --- htdocs/core/class/commonobject.class.php | 11 ++++------- htdocs/product/list.php | 4 ++-- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 5f8a6049a7f..d40406beb09 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -2361,15 +2361,12 @@ abstract class CommonObject } else { $result = $this->fetchCommon($id); } - if (property_exists($this, $field)) { // Set again the property field because it may have been erased by the previous fetch - $this->$field = $value; - } - if ($propfield != $field && property_exists($this, $propfield)) { // Set again the property field because it may have been erased by the previous fetch - $this->$propfield = $value; - } $this->oldcopy = clone $this; - if (property_exists($this->oldcopy, $propfield)) { + if (property_exists($this->oldcopy, $field)) { + $this->oldcopy->$field = $oldvalue; + } + if ($propfield != $field && property_exists($this->oldcopy, $propfield)) { $this->oldcopy->$propfield = $oldvalue; } diff --git a/htdocs/product/list.php b/htdocs/product/list.php index b2085b6dc97..8c13c6db0bf 100644 --- a/htdocs/product/list.php +++ b/htdocs/product/list.php @@ -2305,7 +2305,7 @@ while ($i < $imaxinloop) { if (!empty($arrayfields['p.tosell']['checked'])) { print ''; if (!empty($conf->use_javascript_ajax) && $user->hasRight("produit", "creer") && getDolGlobalString('MAIN_DIRECT_STATUS_UPDATE')) { - print ajax_object_onoff($product_static, 'status', 'tosell', 'ProductStatusOnSell', 'ProductStatusNotOnSell'); + print ajax_object_onoff($product_static, 'status', 'status', 'ProductStatusOnSell', 'ProductStatusNotOnSell'); } else { print $product_static->LibStatut($product_static->status, 5, 0); } @@ -2318,7 +2318,7 @@ while ($i < $imaxinloop) { if (!empty($arrayfields['p.tobuy']['checked'])) { print ''; if (!empty($conf->use_javascript_ajax) && $user->hasRight("produit", "creer") && getDolGlobalString('MAIN_DIRECT_STATUS_UPDATE')) { - print ajax_object_onoff($product_static, 'status_buy', 'tobuy', 'ProductStatusOnBuy', 'ProductStatusNotOnBuy'); + print ajax_object_onoff($product_static, 'status_buy', 'status_buy', 'ProductStatusOnBuy', 'ProductStatusNotOnBuy'); } else { print $product_static->LibStatut($product_static->status_buy, 5, 1); }