From ecb673f15c1e160e2f85e92ae12a1a7feffe4619 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 16 Aug 2021 23:02:55 +0200 Subject: [PATCH] Debug default BOM on product --- htdocs/langs/en_US/products.lang | 2 + htdocs/product/card.php | 44 ++++++++++--------- .../product/class/html.formproduct.class.php | 13 +++--- 3 files changed, 31 insertions(+), 28 deletions(-) diff --git a/htdocs/langs/en_US/products.lang b/htdocs/langs/en_US/products.lang index bf34efe3f79..ae199f4136b 100644 --- a/htdocs/langs/en_US/products.lang +++ b/htdocs/langs/en_US/products.lang @@ -399,3 +399,5 @@ ProductSupplierExtraFields=Additional Attributes (Supplier Prices) DeleteLinkedProduct=Delete the child product linked to the combination PMPValue=Weighted average price PMPValueShort=WAP +DefaultBOM=Default BOM +DefaultBOMDesc=The default BOM recommended to use to manufacture this product. This field can be set only if nature of product is '%s'. \ No newline at end of file diff --git a/htdocs/product/card.php b/htdocs/product/card.php index 04396770aa2..f1729b153b9 100644 --- a/htdocs/product/card.php +++ b/htdocs/product/card.php @@ -1221,8 +1221,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { print ''.$form->textwithpicto($langs->trans("StockLimit"), $langs->trans("StockLimitDesc"), 1).''; print ''; print ''; - - print ''; + print ''; // Stock desired level print ''.$form->textwithpicto($langs->trans("DesiredStock"), $langs->trans("DesiredStockDesc"), 1).''; @@ -1252,7 +1251,9 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { print $form->selectarray('finished', $statutarray, GETPOST('finished', 'alpha'), 1); print ''; } + } + if ($type != 1) { if (empty($conf->global->PRODUCT_DISABLE_WEIGHT)) { // Brut Weight print ''.$langs->trans("Weight").''; @@ -1788,7 +1789,16 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { print $formproduct->selectProductNature('finished', $object->finished); print ''; } + } + if (!$object->isService() && !empty($conf->bom->enabled)) { + print ''.$form->textwithpicto($langs->trans("DefaultBOM"), $langs->trans("DefaultBOMDesc", $langs->transnoentitiesnoconv("Finished"))).''; + $bomkey = "Bom:bom/class/bom.class.php:0:t.status=1 AND t.fk_product=".$object->id; + print $form->selectForForms($bomkey, 'fk_default_bom', $object->fk_default_bom, 1); + print ''; + } + + if (!$object->isService()) { if (empty($conf->global->PRODUCT_DISABLE_WEIGHT)) { // Brut Weight print ''.$langs->trans("Weight").''; @@ -1911,13 +1921,6 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { print ''; - if (!$object->isService() && !empty($conf->bom->enabled)) { - print ''; - } - if (empty($conf->global->PRODUCT_DISABLE_ACCOUNTING)) { if (!empty($conf->accounting->enabled)) { // Accountancy_code_sell @@ -2279,7 +2282,19 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { print $object->getLibFinished(); print ''; } + } + if (!$object->isService() && !empty($conf->bom->enabled) && $object->finished) { + print ''; + } + + if (!$object->isService()) { // Brut Weight if (empty($conf->global->PRODUCT_DISABLE_WEIGHT)) { print ''; } - if (!$object->isService() && !empty($conf->bom->enabled)) { - print ''; - } - - // Other attributes $parameters = array(); include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php'; diff --git a/htdocs/product/class/html.formproduct.class.php b/htdocs/product/class/html.formproduct.class.php index 555bc08d03e..64517c25443 100644 --- a/htdocs/product/class/html.formproduct.class.php +++ b/htdocs/product/class/html.formproduct.class.php @@ -477,18 +477,13 @@ class FormProduct $filter = array(); $filter['t.active'] = 1; - $result = $productNature->fetchAll( - '', - '', - 0, - 0, - $filter - ); + $result = $productNature->fetchAll('', '', 0, 0, $filter); + if ($result < 0) { dol_print_error($db); return -1; } else { - $return .= ''; if ($showempty || ($selected == '' || $selected == '-1')) { $return .= '
'.$form->textwithpicto($langs->trans("DefaultBOM"), $langs->trans("DefaultBOMDesc")).''; - $bomkey = "Bom:bom/class/bom.class.php:0:t.status=1 AND t.fk_product=".$object->id; - print $form->selectForForms($bomkey, 'fk_default_bom', $object->fk_default_bom, 1); - print '
'.$form->textwithpicto($langs->trans("DefaultBOM"), $langs->trans("DefaultBOMDesc", $langs->transnoentitiesnoconv("Finished"))).''; + if ($object->fk_default_bom) { + $bom_static = new BOM($db); + $bom_static->fetch($object->fk_default_bom); + print $bom_static->getNomUrl(1); + } + print '
'.$langs->trans("Weight").''; @@ -2370,17 +2385,6 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { print '
'.$langs->trans("QCFrequency").''.$object->qc_frequency.'
'.$form->textwithpicto($langs->trans("DefaultBOM"), $langs->trans("DefaultBOMDesc")).''; - if ($object->fk_default_bom) { - $bom_static = new BOM($db); - $bom_static->fetch($object->fk_default_bom); - print $bom_static->getNomUrl(1); - } - print '