diff --git a/htdocs/core/class/html.formsetup.class.php b/htdocs/core/class/html.formsetup.class.php
index 2dd729df91d..3ff36b356da 100644
--- a/htdocs/core/class/html.formsetup.class.php
+++ b/htdocs/core/class/html.formsetup.class.php
@@ -1093,6 +1093,7 @@ class FormSetupItem
$out.= $this->langs->trans("NorProspectNorCustomer");
}
} elseif ($this->type == 'product') {
+ require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
$product = new Product($this->db);
$resprod = $product->fetch($this->fieldValue);
if ($resprod > 0) {
diff --git a/htdocs/takepos/invoice.php b/htdocs/takepos/invoice.php
index e3f4a106c67..3657ca7f4b6 100644
--- a/htdocs/takepos/invoice.php
+++ b/htdocs/takepos/invoice.php
@@ -562,13 +562,20 @@ if (empty($reshook)) {
$invoice->fetch_thirdparty();
$array_options = array();
+ $line = array('description' => $prod->description, 'price' => $price, 'tva_tx' => $tva_tx, 'locatax1_tx' => $localtax1_tx, 'locatax2_tx' => $localtax2_tx, 'remise_percent' => $customer->remise_percent, 'price_ttc' => $price_ttc, 'array_options' => $array_options);
+
// complete line by hook
- $parameters = array('prod' => $prod);
- $reshook=$hookmanager->executeHooks('completeTakePosAddLine', $parameters, $invoice, $action);
+ $parameters = array('prod' => $prod, 'line' => $line);
+ $reshook=$hookmanager->executeHooks('completeTakePosAddLine', $parameters, $invoice, $action); // Note that $action and $line may have been modified by some hooks
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
+
if (empty($reshook)) {
- $idoflineadded = $invoice->addline($prod->description, $price, $qty, $tva_tx, $localtax1_tx, $localtax2_tx, $idproduct, $customer->remise_percent, '', 0, 0, 0, '', $price_base_type, $price_ttc, $prod->type, -1, 0, '', 0, (!empty($parent_line)) ? $parent_line : '', null, '', '', $array_options, 100, '', null, 0);
+ if (!empty($hookmanager->resArray)) {
+ $line = $hookmanager->resArray;
+ }
+
+ $idoflineadded = $invoice->addline($line['description'], $line['price'], $qty, $line['tva_tx'], $line['localtax1_tx'], $line['localtax2_tx'], $idproduct, $line['remise_percent'], '', 0, 0, 0, '', $price_base_type, $line['price_ttc'], $prod->type, -1, 0, '', 0, (!empty($parent_line)) ? $parent_line : '', null, '', '', $line['array_options'], 100, '', null, 0);
}
if (!empty($conf->global->TAKEPOS_CUSTOMER_DISPLAY)) {