diff --git a/htdocs/projet/card.php b/htdocs/projet/card.php index 68710622ed1..5745f8590ea 100644 --- a/htdocs/projet/card.php +++ b/htdocs/projet/card.php @@ -371,8 +371,10 @@ if (empty($reshook)) { $idoppstatuswon = (int) dol_getIdFromCode($db, 'WON', 'c_lead_status', 'code', 'rowid'); if ($object->opp_status == $idoppstatuswon) { - // Switch the thirdparty into a customer - $object->thirdparty->setAsCustomer(); + // Switch the thirdparty into a customer (only if thirdparty exists) + if (!empty($object->thirdparty) && !empty($object->thirdparty->id)) { + $object->thirdparty->setAsCustomer(); + } } } } @@ -468,8 +470,10 @@ if (empty($reshook)) { $idoppstatuswon = (int) dol_getIdFromCode($db, 'WON', 'c_lead_status', 'code', 'rowid'); if (!$error && $object->opp_status == $idoppstatuswon) { - // Switch the thirdparty into a customer - $object->thirdparty->setAsCustomer(); + // Switch the thirdparty into a customer (only if thirdparty exists) + if (!empty($object->thirdparty) && !empty($object->thirdparty->id)) { + $object->thirdparty->setAsCustomer(); + } } } }