diff --git a/htdocs/projet/card.php b/htdocs/projet/card.php
index 6221e4c2b87..91f57056ec3 100644
--- a/htdocs/projet/card.php
+++ b/htdocs/projet/card.php
@@ -507,7 +507,11 @@ if ($action == 'create' && $user->rights->projet->creer)
// Thirdparty
if ($conf->societe->enabled)
{
- print '
| '.$langs->trans("ThirdParty").' | ';
+ print ' |
| ';
+ print (empty($conf->global->PROJECT_THIRDPARTY_REQUIRED)?'':'');
+ print $langs->trans("ThirdParty");
+ print (empty($conf->global->PROJECT_THIRDPARTY_REQUIRED)?'':'');
+ print ' | ';
$filteronlist='';
if (! empty($conf->global->PROJECT_FILTER_FOR_THIRDPARTY_LIST)) $filteronlist=$conf->global->PROJECT_FILTER_FOR_THIRDPARTY_LIST;
$text=$form->select_thirdparty_list(GETPOST('socid','int'), 'socid', $filteronlist, 'SelectThirdParty', 1, 0, array(), '', 0, 0, 'minwidth300');
@@ -719,7 +723,11 @@ elseif ($object->id > 0)
// Thirdparty
if ($conf->societe->enabled)
{
- print ' |
| '.$langs->trans("ThirdParty").' | ';
+ print ' |
| ';
+ print (empty($conf->global->PROJECT_THIRDPARTY_REQUIRED)?'':'');
+ print $langs->trans("ThirdParty");
+ print (empty($conf->global->PROJECT_THIRDPARTY_REQUIRED)?'':'');
+ print ' | ';
$filteronlist='';
if (! empty($conf->global->PROJECT_FILTER_FOR_THIRDPARTY_LIST)) $filteronlist=$conf->global->PROJECT_FILTER_FOR_THIRDPARTY_LIST;
$text=$form->select_thirdparty_list($object->thirdparty->id, 'socid', $filteronlist, 'None', 1, 0, array(), '', 0, 0, 'minwidth300');
diff --git a/htdocs/projet/class/project.class.php b/htdocs/projet/class/project.class.php
index edd4c6eed12..1afac184b64 100644
--- a/htdocs/projet/class/project.class.php
+++ b/htdocs/projet/class/project.class.php
@@ -139,7 +139,13 @@ class Project extends CommonObject
dol_syslog(get_class($this)."::create error -1 ref null", LOG_ERR);
return -1;
}
-
+ if (! empty($conf->global->PROJECT_THIRDPARTY_REQUIRED) && ! $this->socid > 0)
+ {
+ $this->error = 'ErrorFieldsRequired';
+ dol_syslog(get_class($this)."::create error -1 ref null", LOG_ERR);
+ return -1;
+ }
+
$this->db->begin();
$sql = "INSERT INTO " . MAIN_DB_PREFIX . "projet (";
|