Browse Source

FIX Link between action and project must use field not the link table

Laurent Destailleur 6 years ago
parent
commit
0886928a64

+ 3 - 3
htdocs/comm/action/card.php

@@ -1302,7 +1302,6 @@ if ($id > 0)
 		print '<tr><td class="titlefieldcreate nowrap">'.$langs->trans("Priority").'</td><td>';
 		print '<input type="text" name="priority" value="'.($object->priority?$object->priority:'').'" size="5">';
 		print '</td></tr>';
-
 		// Object linked
 		if (! empty($object->fk_element) && ! empty($object->elementtype))
 		{
@@ -1610,8 +1609,9 @@ if ($id > 0)
 		print ($object->priority?$object->priority:'');
 		print '</td></tr>';
 
-		// Object linked
-		if (! empty($object->fk_element) && ! empty($object->elementtype))
+		// Object linked (if link is for thirdparty, contact, project it is a recording error. We should not have links in link table
+		// for such objects because there is already a dedicated field into table llx_actioncomm.
+		if (! empty($object->fk_element) && ! empty($object->elementtype) && ! in_array($object->elementtype, array('societe','contact','project')))
 		{
 			include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
 			print '<tr><td>'.$langs->trans("LinkedObject").'</td>';

+ 7 - 2
htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php

@@ -841,8 +841,13 @@ class InterfaceActionsAuto extends DolibarrTriggers
 		$actioncomm->email_subject = $object->email_subject;
 		$actioncomm->errors_to     = $object->errors_to;
 
-		$actioncomm->fk_element  = $elementid;
-		$actioncomm->elementtype = $elementtype;
+		// Object linked (if link is for thirdparty, contact, project it is a recording error. We should not have links in link table
+		// for such objects because there is already a dedicated field into table llx_actioncomm.
+		if (! in_array($elementtype, array('societe','contact','project')))
+		{
+			$actioncomm->fk_element  = $elementid;
+			$actioncomm->elementtype = $elementtype;
+		}
 
 		if (property_exists($object,'attachedfiles') && is_array($object->attachedfiles) && count($object->attachedfiles)>0) {
 			$actioncomm->attachedfiles=$object->attachedfiles;