From a41622707e3d44f778e8978f94de8f038956fd73 Mon Sep 17 00:00:00 2001 From: atm-corentin Date: Mon, 22 Dec 2025 14:26:38 +0100 Subject: [PATCH] Fix crash when opportunity won without third-party --- htdocs/projet/card.php | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) 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(); + } } } }