From f209cc5a94ed0d932b6e03de0378391f283669d1 Mon Sep 17 00:00:00 2001 From: HENRY Florian Date: Sat, 18 Nov 2023 02:15:57 +0100 Subject: [PATCH] fix: update setcost_price in htdocs/product/fournisseurs.php (#26700) * fix: update setcost_price in htdocs/product/fournisseurs.php * bettre fix --------- Co-authored-by: Laurent Destailleur --- htdocs/product/card.php | 3 ++- htdocs/product/class/product.class.php | 3 +-- htdocs/product/fournisseurs.php | 3 ++- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/htdocs/product/card.php b/htdocs/product/card.php index b9395315d71..6f7eea81049 100644 --- a/htdocs/product/card.php +++ b/htdocs/product/card.php @@ -738,7 +738,8 @@ if (empty($reshook)) { $action = ''; } else { if ($object->id > 0) { - $object->oldcopy = clone $object; + //Need dol_clone methode 1 (same object class) because update product use hasbatch() method on oldcopy + $object->oldcopy = dol_clone($object, 1); if (empty($conf->global->PRODUCT_GENERATE_REF_AFTER_FORM)) { $object->ref = $ref; diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index 0e77ffcd5b7..10936d9d1fc 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -1149,9 +1149,8 @@ class Product extends CommonObject if ($result >= 0) { // $this->oldcopy should have been set by the caller of update (here properties were already modified) if (empty($this->oldcopy)) { - $this->oldcopy = dol_clone($this); + $this->oldcopy = dol_clone($this, 1); } - // Test if batch management is activated on existing product // If yes, we create missing entries into product_batch if ($this->hasbatch() && !$this->oldcopy->hasbatch()) { diff --git a/htdocs/product/fournisseurs.php b/htdocs/product/fournisseurs.php index 95a98ebc2d3..2ab55df752b 100644 --- a/htdocs/product/fournisseurs.php +++ b/htdocs/product/fournisseurs.php @@ -141,7 +141,8 @@ if (empty($reshook)) { if ($action == 'setcost_price') { if ($id) { $result = $object->fetch($id); - $object->oldcopy = dol_clone($object, 2); + //Need dol_clone methode 1 (same object class) because update product use hasbatch method on oldcopy + $object->oldcopy = dol_clone($object, 1); $object->cost_price = price2num($cost_price); $result = $object->update($object->id, $user); if ($result > 0) {