diff --git a/htdocs/core/class/commondocgenerator.class.php b/htdocs/core/class/commondocgenerator.class.php index 3167bd0c64c..21c1cce4cfd 100644 --- a/htdocs/core/class/commondocgenerator.class.php +++ b/htdocs/core/class/commondocgenerator.class.php @@ -809,26 +809,38 @@ abstract class CommonDocGenerator * * @param Object $object Dolibarr Object * @param Translate $outputlangs Language object for output - * @param boolean $recursive Want to fetch child array or child object + * @param boolean|int $recursive Want to fetch child array or child object. * @return array Array of substitution key->code */ - public function get_substitutionarray_each_var_object(&$object, $outputlangs, $recursive = true) + public function get_substitutionarray_each_var_object(&$object, $outputlangs, $recursive = 1) { // phpcs:enable $array_other = array(); if (!empty($object)) { foreach ($object as $key => $value) { + if (in_array($key, array('db', 'fields', 'lines', 'modelpdf', 'model_pdf'))) { // discard some properties + continue; + } if (!empty($value)) { if (!is_array($value) && !is_object($value)) { $array_other['object_'.$key] = $value; } elseif (is_array($value) && $recursive) { - $array_other['object_'.$key] = $this->get_substitutionarray_each_var_object($value, $outputlangs, false); + $tmparray = $this->get_substitutionarray_each_var_object($value, $outputlangs, 0); + foreach ($tmparray as $key2 => $value2) { + $array_other['object_'.$key.'_'.preg_replace('/^object_/', '', $key2)] = $value2; + } } elseif (is_object($value) && $recursive) { - $array_other['object_'.$key] = $this->get_substitutionarray_each_var_object($value, $outputlangs, false); + $tmparray = $this->get_substitutionarray_each_var_object($value, $outputlangs, 0); + foreach ($tmparray as $key2 => $value2) { + $array_other['object_'.$key.'_'.preg_replace('/^object_/', '', $key2)] = $value2; + } } } } } + + //var_dump($array_other); + return $array_other; } diff --git a/htdocs/core/modules/bom/doc/doc_generic_bom_odt.modules.php b/htdocs/core/modules/bom/doc/doc_generic_bom_odt.modules.php index 31c20cf1ecd..c070e3b1058 100644 --- a/htdocs/core/modules/bom/doc/doc_generic_bom_odt.modules.php +++ b/htdocs/core/modules/bom/doc/doc_generic_bom_odt.modules.php @@ -246,6 +246,7 @@ class doc_generic_bom_odt extends ModelePDFBom } $object->fetch_thirdparty(); + $object->fetch_product(); $dir = $conf->bom->multidir_output[isset($object->entity) ? $object->entity : 1]; $objectref = dol_sanitizeFileName($object->ref);