Fix crash when opportunity won without third-party

This commit is contained in:
atm-corentin
2025-12-22 14:26:38 +01:00
parent a50394e4df
commit a41622707e

View File

@@ -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();
}
}
}
}