Fix set status of product with MAIN_DIRECT_STATUS_UPDATE

This commit is contained in:
Laurent Destailleur 2026-03-24 18:53:26 +01:00
parent ea051503be
commit fe04dd02f5
2 changed files with 6 additions and 9 deletions

View file

@ -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;
}

View file

@ -2305,7 +2305,7 @@ while ($i < $imaxinloop) {
if (!empty($arrayfields['p.tosell']['checked'])) {
print '<td class="center nowrap">';
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 '<td class="center nowrap">';
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);
}