diff --git a/htdocs/core/class/html.formcompany.class.php b/htdocs/core/class/html.formcompany.class.php index 3131b264e5d..abcec3a00e3 100644 --- a/htdocs/core/class/html.formcompany.class.php +++ b/htdocs/core/class/html.formcompany.class.php @@ -747,7 +747,8 @@ class FormCompany extends Form if (getDolGlobalString('COMPANY_SHOW_ADDRESS_SELECTLIST')) { $sql .= " LEFT JOIN " . $this->db->prefix() . "c_country as dictp ON dictp.rowid = s.fk_pays"; } - $sql .= " WHERE s.entity IN (" . getEntity('societe') . ")"; + // Filter on active third parties only (status = 1) Closed third parties must not be selectable + $sql .= " WHERE s.entity IN (" . getEntity('societe') . ") AND s.status = 1"; // For ajax search we limit here. For combo list, we limit later if (is_array($limitto) && count($limitto)) { $sql .= " AND s.rowid IN (" . $this->db->sanitize(implode(',', $limitto)) . ")"; diff --git a/htdocs/societe/ajax/ajaxcompanies.php b/htdocs/societe/ajax/ajaxcompanies.php index c831af0a28d..ab0ffded858 100644 --- a/htdocs/societe/ajax/ajaxcompanies.php +++ b/htdocs/societe/ajax/ajaxcompanies.php @@ -108,7 +108,8 @@ $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; if (getDolGlobalString('COMPANY_SHOW_ADDRESS_SELECTLIST')) { $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as dictp ON dictp.rowid = s.fk_pays"; } -$sql .= " WHERE s.entity IN (".getEntity('societe').")"; +// Filter on active third parties only (status = 1) Closed third parties must not be selectable +$sql .= " WHERE s.entity IN (".getEntity('societe').") AND s.status = 1"; if ($socid) { $sql .= " AND ("; // Add criteria on name/code