FIX ODT tags for subobjects {object_subobject_yyy} was not working.

This commit is contained in:
Laurent Destailleur 2022-06-07 19:59:33 +02:00
parent 8303347ab8
commit 7ee4cccc84
2 changed files with 17 additions and 4 deletions

View File

@ -809,26 +809,38 @@ abstract class CommonDocGenerator
* *
* @param Object $object Dolibarr Object * @param Object $object Dolibarr Object
* @param Translate $outputlangs Language object for output * @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 * @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 // phpcs:enable
$array_other = array(); $array_other = array();
if (!empty($object)) { if (!empty($object)) {
foreach ($object as $key => $value) { foreach ($object as $key => $value) {
if (in_array($key, array('db', 'fields', 'lines', 'modelpdf', 'model_pdf'))) { // discard some properties
continue;
}
if (!empty($value)) { if (!empty($value)) {
if (!is_array($value) && !is_object($value)) { if (!is_array($value) && !is_object($value)) {
$array_other['object_'.$key] = $value; $array_other['object_'.$key] = $value;
} elseif (is_array($value) && $recursive) { } 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) { } 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; return $array_other;
} }

View File

@ -246,6 +246,7 @@ class doc_generic_bom_odt extends ModelePDFBom
} }
$object->fetch_thirdparty(); $object->fetch_thirdparty();
$object->fetch_product();
$dir = $conf->bom->multidir_output[isset($object->entity) ? $object->entity : 1]; $dir = $conf->bom->multidir_output[isset($object->entity) ? $object->entity : 1];
$objectref = dol_sanitizeFileName($object->ref); $objectref = dol_sanitizeFileName($object->ref);