diff --git a/htdocs/product/fournisseurs.php b/htdocs/product/fournisseurs.php index a6922471bd1..c7a65e456b7 100644 --- a/htdocs/product/fournisseurs.php +++ b/htdocs/product/fournisseurs.php @@ -182,6 +182,7 @@ if (empty($reshook)) { } if ($action == 'save_price') { + $ref_fourn_price_id = GETPOSTINT('ref_fourn_price_id'); $id_fourn = GETPOST("id_fourn"); if (empty($id_fourn)) { $id_fourn = GETPOST("search_id_fourn"); @@ -266,7 +267,7 @@ if (empty($reshook)) { if (!$error) { $db->begin(); - if (!$error) { + if (empty($ref_fourn_price_id)) { $ret = $object->add_fournisseur($user, $id_fourn, $ref_fourn_old, $quantity); // This insert record with no value for price. Values are update later with update_buyprice if ($ret == -3) { $error++; @@ -287,8 +288,8 @@ if (empty($reshook)) { if (!$error) { $supplier = new Fournisseur($db); $result = $supplier->fetch($id_fourn); - if (GETPOSTISSET('ref_fourn_price_id')) { - $object->fetch_product_fournisseur_price(GETPOST('ref_fourn_price_id', 'int')); + if ($ref_fourn_price_id > 0) { + $object->fetch_product_fournisseur_price($ref_fourn_price_id); } $extralabels = $extrafields->fetch_name_optionals_label("product_fournisseur_price"); $extrafield_values = $extrafields->getOptionalsFromPost("product_fournisseur_price");