Merge pull request #13731 from simicar29/11.0-reception

Clean line extrafields when deleting reception
This commit is contained in:
Laurent Destailleur 2020-04-24 15:16:51 +02:00 committed by GitHub
commit 9764af7e9c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 23 additions and 2 deletions

View File

@ -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;
}

View File

@ -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();