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

This commit is contained in:
Laurent Destailleur 2018-11-19 14:38:30 +01:00
parent 1e1ccd4c88
commit 0886928a64
2 changed files with 10 additions and 5 deletions

View File

@ -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>';

View File

@ -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;