diff --git a/htdocs/fourn/class/fournisseur.commande.dispatch.class.php b/htdocs/fourn/class/fournisseur.commande.dispatch.class.php index b453653c681..cec23c590b2 100644 --- a/htdocs/fourn/class/fournisseur.commande.dispatch.class.php +++ b/htdocs/fourn/class/fournisseur.commande.dispatch.class.php @@ -303,6 +303,7 @@ class CommandeFournisseurDispatch extends CommonObject $this->batch = $obj->batch; $this->eatby = $this->db->jdate($obj->eatby); $this->sellby = $this->db->jdate($obj->sellby); + $this->fetch_optionals(); } $this->db->free($resql); @@ -439,6 +440,16 @@ class CommandeFournisseurDispatch extends CommonObject } } + // Remove extrafields + if (!$error) { + $result = $this->deleteExtraFields(); + if ($result < 0) + { + $error++; + dol_syslog(get_class($this)."::delete error deleteExtraFields ".$this->error, LOG_ERR); + } + } + if (! $error) { $sql = "DELETE FROM ".MAIN_DB_PREFIX.$this->table_element; @@ -689,6 +700,7 @@ class CommandeFournisseurDispatch extends CommonObject $line->batch = $obj->batch; $line->eatby = $this->db->jdate($obj->eatby); $line->sellby = $this->db->jdate($obj->sellby); + $line->fetch_optionals(); $this->lines[$line->id] = $line; } diff --git a/htdocs/reception/class/reception.class.php b/htdocs/reception/class/reception.class.php index 5552d45380e..ce718fda964 100644 --- a/htdocs/reception/class/reception.class.php +++ b/htdocs/reception/class/reception.class.php @@ -763,8 +763,13 @@ class Reception extends CommonObject } // extrafields + $line->array_options = $supplierorderline->array_options; if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && is_array($array_options) && count($array_options) > 0) // For avoid conflicts if trigger used - $line->array_options = $array_options; + { + foreach ($array_options as $key => $value) { + $line->array_options[$key] = $value; + } + } $line->fk_product = $fk_product; $line->fk_commande = $supplierorderline->fk_commande; @@ -938,10 +943,14 @@ class Reception extends CommonObject if (!$error) { + $main = MAIN_DB_PREFIX . 'commande_fournisseur_dispatch'; + $ef = $main . "_extrafields"; + $sqlef = "DELETE FROM $ef WHERE fk_object IN (SELECT rowid FROM $main WHERE fk_reception = " . $this->id . ")"; + $sql = "DELETE FROM ".MAIN_DB_PREFIX."commande_fournisseur_dispatch"; $sql .= " WHERE fk_reception = ".$this->id; - if ($this->db->query($sql)) + if ($this->db->query($sqlef) && $this->db->query($sql)) { // Delete linked object $res = $this->deleteObjectLinked();