diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index e36eef20ff4c6d360d81af5d5fc7c367661382be..3306d38f214d8ee13a7ffeef6704639c07e16df4 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -598,10 +598,10 @@ abstract class CommonObject { global $conf; - if (empty($this->socid) && empty($this->fk_soc)) return 0; + if (empty($this->socid) && empty($this->fk_soc) && empty($this->fk_thirdparty)) return 0; $thirdparty = new Societe($this->db); - $result=$thirdparty->fetch(isset($this->socid)?$this->socid:$this->fk_soc); + $result=$thirdparty->fetch(isset($this->socid)?$this->socid:(isset($this->fk_soc)?$this->fk_soc:$this->fk_thirdparty)); $this->client = $thirdparty; // deprecated $this->thirdparty = $thirdparty;