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 <eldy@destailleur.fr>
This commit is contained in:
HENRY Florian
2023-11-18 02:15:57 +01:00
committed by GitHub
parent e487d663d6
commit f209cc5a94
3 changed files with 5 additions and 4 deletions

View File

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

View File

@@ -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()) {

View File

@@ -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) {