From 73bdb715076c8a101bc7507a0a35a686d919e389 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 3 Oct 2023 19:54:06 +0200 Subject: [PATCH] Fix bom --- htdocs/bom/bom_list.php | 12 +++++++++++- htdocs/bom/class/bom.class.php | 6 ++---- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/htdocs/bom/bom_list.php b/htdocs/bom/bom_list.php index 07f0879589a..40983f8a22e 100644 --- a/htdocs/bom/bom_list.php +++ b/htdocs/bom/bom_list.php @@ -27,6 +27,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; require_once DOL_DOCUMENT_ROOT.'/bom/class/bom.class.php'; +require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; // Load translation files required by the page $langs->loadLangs(array('mrp', 'other')); @@ -687,8 +688,17 @@ while ($i < $imaxinloop) { print ''; print '
'; } + + // TODO Use a cache for product + if (!empty($obj->fk_product)) { + $prod = new Product($db); + $prod->fetch($obj->fk_product); + } else { + $prod = null; + } + // Output kanban - print $object->getKanbanView('', array('selected' => in_array($object->id, $arrayofselected))); + print $object->getKanbanView('', array('prod'=>$prod, 'selected' => in_array($object->id, $arrayofselected))); if ($i == ($imaxinloop - 1)) { print '
'; print ''; diff --git a/htdocs/bom/class/bom.class.php b/htdocs/bom/class/bom.class.php index bf942c7ad86..3cc3b6c6770 100644 --- a/htdocs/bom/class/bom.class.php +++ b/htdocs/bom/class/bom.class.php @@ -1617,9 +1617,6 @@ class BOM extends CommonObject $selected = (empty($arraydata['selected']) ? 0 : $arraydata['selected']); - $prod = new Product($db); - $prod->fetch($this->fk_product); - $return = '
'; $return .= '
'; $return .= ''; @@ -1636,7 +1633,8 @@ class BOM extends CommonObject $return .= ''.$this->fields['bomtype']['arrayofkeyval'][1].''; } } - if (property_exists($this, 'fk_product') && !is_null($this->fk_product)) { + if (!empty($arraydata['prod'])) { + $prod = $arraydata['prod']; $return .= '
'.$prod->getNomUrl(1).''; } if (method_exists($this, 'getLibStatut')) {