diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index f6d5677af16..001a4972dd7 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -992,7 +992,12 @@ class Commande extends CommonOrder $line->marge_tx = $marginInfos[1]; $line->marque_tx = $marginInfos[2]; - $this->lines[$i] = $line; + // get extrafields from original line + $object->lines[$i]->fetch_optionals($object->lines[$i]->rowid); + foreach($object->lines[$i]->array_options as $options_key => $value) + $line->array_options[$options_key] = $value; + + $this->lines[$i] = $line; } $this->socid = $object->socid; @@ -1011,6 +1016,11 @@ class Commande extends CommonOrder $this->origin = $object->element; $this->origin_id = $object->id; + // get extrafields from original line + $object->fetch_optionals($object->id); + foreach($object->array_options as $options_key => $value) + $this->array_options[$options_key] = $value; + // Possibility to add external linked objects with hooks $this->linked_objects[$this->origin] = $this->origin_id; if (is_array($object->other_linked_objects) && ! empty($object->other_linked_objects)) diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 6e4fbc03c66..6def5560deb 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -725,6 +725,11 @@ class Facture extends CommonInvoice $marginInfos = getMarginInfos($object->lines[$i]->subprice, $object->lines[$i]->remise_percent, $object->lines[$i]->tva_tx, $object->lines[$i]->localtax1_tx, $object->lines[$i]->localtax2_tx, $object->lines[$i]->fk_fournprice, $object->lines[$i]->pa_ht); $line->pa_ht = $marginInfos[0]; + // get extrafields from original line + $object->lines[$i]->fetch_optionals($object->lines[$i]->rowid); + foreach($object->lines[$i]->array_options as $options_key => $value) + $line->array_options[$options_key] = $value; + $this->lines[$i] = $line; } @@ -744,6 +749,11 @@ class Facture extends CommonInvoice $this->origin = $object->element; $this->origin_id = $object->id; + // get extrafields from original line + $object->fetch_optionals($object->id); + foreach($object->array_options as $options_key => $value) + $this->array_options[$options_key] = $value; + // Possibility to add external linked objects with hooks $this->linked_objects[$this->origin] = $this->origin_id; if (! empty($object->other_linked_objects) && is_array($object->other_linked_objects)) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 72eeba4d59f..4a21bfe3cda 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -2237,7 +2237,7 @@ abstract class CommonObject { $attributeKey = substr($key,8); // Remove 'options_' prefix // Add field of attribut - if ($extrafields->attribute_type[$attributeKey] != 'separate') // Only for other type of separate + if (isset($extrafields->attribute_type[$attributeKey]) && $extrafields->attribute_type[$attributeKey] != 'separate') // Only for other type of separate $sql.=",".$attributeKey; } $sql .= ") VALUES (".$this->id; @@ -2245,7 +2245,7 @@ abstract class CommonObject { $attributeKey = substr($key,8); // Remove 'options_' prefix // Add field o fattribut - if($extrafields->attribute_type[$attributeKey] != 'separate') // Only for other type of separate) + if(isset($extrafields->attribute_type[$attributeKey]) && $extrafields->attribute_type[$attributeKey] != 'separate') // Only for other type of separate) { if ($this->array_options[$key] != '') {