diff --git a/htdocs/asset/class/asset.class.php b/htdocs/asset/class/asset.class.php index 84aae9ed724..6cb18a28394 100644 --- a/htdocs/asset/class/asset.class.php +++ b/htdocs/asset/class/asset.class.php @@ -1036,13 +1036,12 @@ class Asset extends CommonObject } // Delete old lines - $sql = "DELETE " . MAIN_DB_PREFIX . "asset_depreciation FROM " . MAIN_DB_PREFIX . "asset_depreciation"; - $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accounting_bookkeeping as ab ON ab.doc_type = 'asset' AND ab.fk_docdet = " . MAIN_DB_PREFIX . "asset_depreciation.rowid"; - $sql .= " WHERE " . MAIN_DB_PREFIX . "asset_depreciation.fk_asset = " . (int) $this->id; - $sql .= " AND " . MAIN_DB_PREFIX . "asset_depreciation.depreciation_mode = '" . $this->db->escape($mode_key) . "'"; - $sql .= " AND ab.fk_docdet IS NULL"; + $sql = "DELETE FROM " . MAIN_DB_PREFIX . "asset_depreciation"; + $sql .= " WHERE fk_asset = " . (int) $this->id; + $sql .= " AND depreciation_mode = '" . $this->db->escape($mode_key) . "'"; + $sql .= " AND NOT EXISTS (SELECT fk_docdet FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping WHERE doc_type = 'asset' AND fk_docdet = " . MAIN_DB_PREFIX . "asset_depreciation.rowid)"; if ($last_depreciation_date !== "") { - $sql .= " AND " . MAIN_DB_PREFIX . "asset_depreciation.ref != ''"; + $sql .= " AND ref <> ''"; } $resql = $this->db->query($sql); if (!$resql) { diff --git a/htdocs/core/actions_massactions.inc.php b/htdocs/core/actions_massactions.inc.php index 8be73613171..162ead0463a 100644 --- a/htdocs/core/actions_massactions.inc.php +++ b/htdocs/core/actions_massactions.inc.php @@ -1231,9 +1231,13 @@ EOPHAN; $db->begin(); $nbok = 0; + + $objecttmp = new $objectclass($db); + foreach ($toselect as $toselectid) { - $objecttmp = new $objectclass($db); + $objecttmp->thirdparty = null; // Clear if another value was already set by fetch_thirdparty later $result = $objecttmp->fetch($toselectid); + if ($result > 0) { $outputlangs = $langs; $newlang = ''; diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index 6738f53d5ff..e270cb5a2bb 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -546,7 +546,10 @@ class CommandeFournisseur extends CommonOrder $this->ref = $obj->ref; $this->ref_supplier = $obj->ref_supplier; + $this->socid = $obj->fk_soc; + $this->thirdparty = null; // Clear if another value was already set by fetch_thirdparty + $this->fourn_id = $obj->fk_soc; $this->statut = $obj->status; // deprecated $this->status = $obj->status; diff --git a/htdocs/fourn/class/fournisseur.facture.class.php b/htdocs/fourn/class/fournisseur.facture.class.php index 560b5ef6b07..9f7c4eb523b 100644 --- a/htdocs/fourn/class/fournisseur.facture.class.php +++ b/htdocs/fourn/class/fournisseur.facture.class.php @@ -1013,6 +1013,8 @@ class FactureFournisseur extends CommonInvoice $this->socid = $obj->socid; + $this->thirdparty = null; // Clear if another value was already set by fetch_thirdparty + // Retrieve all extrafield // fetch optionals attributes and labels $this->fetch_optionals();