diff --git a/htdocs/projet/card.php b/htdocs/projet/card.php index db00efbc520..d8e5873ed9b 100644 --- a/htdocs/projet/card.php +++ b/htdocs/projet/card.php @@ -365,16 +365,14 @@ if (empty($reshook)) { setEventMessages($langs->trans("ErrorOppStatusRequiredIfAmount"), null, 'errors'); } - if (!$error) { - if ((int) $object->thirdparty->client == 0 || (int) $object->thirdparty->client == 2) { // If not yet customer - // Get ID of the special opportunity status code 'WON' - $idoppstatuswon = (int) dol_getIdFromCode($db, 'WON', 'c_lead_status', 'code', 'rowid'); + if (!$error && !is_null($object->thirdparty) && ((int) $object->thirdparty->client == 0 || (int) $object->thirdparty->client == 2)) { // If not yet customer + // Get ID of the special opportunity status code 'WON' + $idoppstatuswon = (int) dol_getIdFromCode($db, 'WON', 'c_lead_status', 'code', 'rowid'); - if ($object->opp_status == $idoppstatuswon) { - // Switch the thirdparty into a customer (only if thirdparty exists) - if (!empty($object->thirdparty) && !empty($object->thirdparty->id)) { - $object->thirdparty->setAsCustomer(); - } + if ($object->opp_status == $idoppstatuswon) { + // Switch the thirdparty into a customer (only if thirdparty exists) + if (!empty($object->thirdparty) && !empty($object->thirdparty->id)) { + $object->thirdparty->setAsCustomer(); } } } @@ -465,7 +463,7 @@ if (empty($reshook)) { // If opportunities are used and the customer is not yet a customer if (getDolGlobalString('PROJECT_USE_OPPORTUNITIES') && $object->usage_opportunity) { - if ((int) $object->thirdparty->client == 0 || (int) $object->thirdparty->client == 2) { // If not yet customer + if (!is_null($object->thirdparty) && ((int) $object->thirdparty->client == 0 || (int) $object->thirdparty->client == 2)) { // If not yet customer // Get ID of the special opportunity status code 'WON' $idoppstatuswon = (int) dol_getIdFromCode($db, 'WON', 'c_lead_status', 'code', 'rowid');