Merge pull request #20256 from marc-dll/13.0_FIX_project_creation_role_not_found
FIX: project creation prevented if PROJECTLEADER contact role renamed, de-activated or deleted
This commit is contained in:
commit
6617cbc531
@ -267,4 +267,5 @@ NewInvoice=New invoice
|
|||||||
OneLinePerTask=One line per task
|
OneLinePerTask=One line per task
|
||||||
OneLinePerPeriod=One line per period
|
OneLinePerPeriod=One line per period
|
||||||
RefTaskParent=Ref. Parent Task
|
RefTaskParent=Ref. Parent Task
|
||||||
ProfitIsCalculatedWith=Profit is calculated using
|
ProfitIsCalculatedWith=Profit is calculated using
|
||||||
|
ErrorPROJECTLEADERRoleMissingRestoreIt=The "PROJECTLEADER" role is missing or has been de-activited, please restore in the dictionary of contact types
|
||||||
|
|||||||
@ -174,10 +174,14 @@ if (empty($reshook))
|
|||||||
if (!$error && $result > 0)
|
if (!$error && $result > 0)
|
||||||
{
|
{
|
||||||
// Add myself as project leader
|
// Add myself as project leader
|
||||||
$typeofcontact = 'PROJECTLEADER'; // TODO If use rename this code in dictionary, the add_contact will generate an error.
|
$typeofcontact = 'PROJECTLEADER';
|
||||||
$result = $object->add_contact($user->id, $typeofcontact, 'internal');
|
$result = $object->add_contact($user->id, $typeofcontact, 'internal');
|
||||||
if ($result < 0)
|
|
||||||
{
|
// -3 means type not found (PROJECTLEADER renamed, de-activated or deleted), so don't prevent creation if it has been the case
|
||||||
|
if ($result == -3) {
|
||||||
|
setEventMessage('ErrorPROJECTLEADERRoleMissingRestoreIt', 'errors');
|
||||||
|
$error++;
|
||||||
|
} elseif ($result < 0) {
|
||||||
$langs->load("errors");
|
$langs->load("errors");
|
||||||
setEventMessages($object->error, $object->errors, 'errors');
|
setEventMessages($object->error, $object->errors, 'errors');
|
||||||
$error++;
|
$error++;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user