diff --git a/htdocs/bom/bom_card.php b/htdocs/bom/bom_card.php index 2eff03dce82..5466fb54f8f 100644 --- a/htdocs/bom/bom_card.php +++ b/htdocs/bom/bom_card.php @@ -197,7 +197,7 @@ if (empty($reshook)) { } } - // Add line + // Update line if ($action == 'updateline' && $user->rights->bom->write) { $langs->load('errors'); $error = 0; @@ -213,26 +213,24 @@ if (empty($reshook)) { $error++; } - $bomline = new BOMLine($db); - $bomline->fetch($lineid); - $bomline->qty = $qty; - $bomline->qty_frozen = (int) $qty_frozen; - $bomline->disable_stock_change = (int) $disable_stock_change; - $bomline->efficiency = $efficiency; + if (!$error) { - $result = $bomline->update($user); - if ($result <= 0) { - setEventMessages($bomline->error, $bomline->errors, 'errors'); - $action = ''; - } else { - unset($_POST['idprod']); - unset($_POST['qty']); - unset($_POST['qty_frozen']); - unset($_POST['disable_stock_change']); + $bomline = new BOMLine($db); + $bomline->fetch($lineid); - $object->fetchLines(); + $result = $object->updateLine($lineid, $qty, (int)$qty_frozen, (int)$disable_stock_change, $efficiency, $bomline->position, $bomline->import_key); - $object->calculateCosts(); + if ($result <= 0) { + setEventMessages($object->error, $object->errors, 'errors'); + $action = ''; + } else { + unset($_POST['idprod']); + unset($_POST['qty']); + unset($_POST['qty_frozen']); + unset($_POST['disable_stock_change']); + + $object->fetchLines(); + } } } } diff --git a/htdocs/bom/class/api_boms.class.php b/htdocs/bom/class/api_boms.class.php index 3c06a658b96..fb7d175a229 100644 --- a/htdocs/bom/class/api_boms.class.php +++ b/htdocs/bom/class/api_boms.class.php @@ -391,7 +391,6 @@ class Boms extends DolibarrApi $request_data->disable_stock_change, $request_data->efficiency, $request_data->position, - $request_data->fk_bom_child, $request_data->import_key ); diff --git a/htdocs/bom/class/bom.class.php b/htdocs/bom/class/bom.class.php index e774e4ddacf..ec659502e60 100644 --- a/htdocs/bom/class/bom.class.php +++ b/htdocs/bom/class/bom.class.php @@ -616,13 +616,13 @@ class BOM extends CommonObject * @param string $import_key Import Key * @return int <0 if KO, Id of updated BOM-Line if OK */ - public function updateLine($rowid, $qty, $qty_frozen = 0, $disable_stock_change = 0, $efficiency = 1.0, $position = -1, $fk_bom_child = null, $import_key = null) + public function updateLine($rowid, $qty, $qty_frozen = 0, $disable_stock_change = 0, $efficiency = 1.0, $position = -1, $import_key = null) { global $mysoc, $conf, $langs, $user; $logtext = "::updateLine bomid=$this->id, qty=$qty, qty_frozen=$qty_frozen, disable_stock_change=$disable_stock_change, efficiency=$efficiency"; - $logtext .= ", fk_bom_child=$fk_bom_child, import_key=$import_key"; + $logtext .= ", import_key=$import_key"; dol_syslog(get_class($this).$logtext, LOG_DEBUG); if ($this->statut == self::STATUS_DRAFT) { @@ -641,9 +641,6 @@ class BOM extends CommonObject if (empty($efficiency)) { $efficiency = 1.0; } - if (empty($fk_bom_child)) { - $fk_bom_child = null; - } if (empty($import_key)) { $import_key = null; } @@ -688,7 +685,6 @@ class BOM extends CommonObject $this->line->qty_frozen = $qty_frozen; $this->line->disable_stock_change = $disable_stock_change; $this->line->efficiency = $efficiency; - $this->line->fk_bom_child = $fk_bom_child; $this->line->import_key = $import_key; $this->line->position = $rankToUse;