From 6a1596247748f994c0c1dddd9710bad2a034011e Mon Sep 17 00:00:00 2001 From: atm-lena Date: Thu, 15 Sep 2022 16:02:49 +0200 Subject: [PATCH 1/2] CalculateCosts function : add hook --- htdocs/bom/class/bom.class.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/htdocs/bom/class/bom.class.php b/htdocs/bom/class/bom.class.php index 539046c593b..512044fedb2 100644 --- a/htdocs/bom/class/bom.class.php +++ b/htdocs/bom/class/bom.class.php @@ -1028,10 +1028,20 @@ class BOM extends CommonObject */ public function calculateCosts() { + global $hookmanager; + include_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; $this->unit_cost = 0; $this->total_cost = 0; + $parameters=array(); + $reshook = $hookmanager->executeHooks('calculateCostsBom', $parameters, $this); // Note that $action and $object may have been modified by hook + + + if ($reshook > 0) { + return $hookmanager->resPrint; + } + if (is_array($this->lines) && count($this->lines)) { require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.product.class.php'; $productFournisseur = new ProductFournisseur($this->db); @@ -1078,6 +1088,9 @@ class BOM extends CommonObject $this->unit_cost = price2num($this->total_cost * $this->qty, 'MU'); } } + + + } /** From 2c017d4f78c952aa82e1c1427dd30d1481881748 Mon Sep 17 00:00:00 2001 From: atm-lena Date: Thu, 15 Sep 2022 16:04:32 +0200 Subject: [PATCH 2/2] Clean --- htdocs/bom/class/bom.class.php | 3 --- 1 file changed, 3 deletions(-) diff --git a/htdocs/bom/class/bom.class.php b/htdocs/bom/class/bom.class.php index 512044fedb2..0e57bebd922 100644 --- a/htdocs/bom/class/bom.class.php +++ b/htdocs/bom/class/bom.class.php @@ -1088,9 +1088,6 @@ class BOM extends CommonObject $this->unit_cost = price2num($this->total_cost * $this->qty, 'MU'); } } - - - } /**