diff --git a/htdocs/comm/action/document.php b/htdocs/comm/action/document.php
index 9fcbca3e743ef67549bf1149e694b761cc1dfd2f..042f330b19992ebe5ffd5f233c3588ed96495d2f 100755
--- a/htdocs/comm/action/document.php
+++ b/htdocs/comm/action/document.php
@@ -263,7 +263,7 @@ if ($objectid > 0)
 
 		// Affiche formulaire upload
 	   	$formfile=new FormFile($db);
-		$formfile->form_attach_new_file(DOL_URL_ROOT.'/comm/action/document.php?id='.$act->id,'',0,0,($user->rights->agenda->myactions->create||$user->rights->agenda->allactions->create));
+		$formfile->form_attach_new_file(DOL_URL_ROOT.'/comm/action/document.php?id='.$act->id,'',0,0,($user->rights->agenda->myactions->create||$user->rights->agenda->allactions->create),50,$act);
 
 
 		// List of document
diff --git a/htdocs/core/class/fileupload.class.php b/htdocs/core/class/fileupload.class.php
index c5e830179400d20e58725ae9b4cc7423ecdb904b..a86073e6969e2fa65d9eee71de7359bcf2ed7ac8 100644
--- a/htdocs/core/class/fileupload.class.php
+++ b/htdocs/core/class/fileupload.class.php
@@ -56,6 +56,8 @@ class FileUpload
 			$filename = $regs[2];
 		}
 
+		$parentForeignKey = '';
+
 		// For compatibility
 		if ($element == 'propal') {
 			$pathname = 'comm/propal';
@@ -69,6 +71,14 @@ class FileUpload
 			$element = $pathname = 'projet';
 			$dir_output=$conf->$element->dir_output;
 		}
+		elseif ($element == 'project_task') {
+			$pathname = 'projet'; $filename='task';
+			$dir_output=$conf->projet->dir_output;
+			$parentForeignKey = 'fk_project';
+			$parentClass = 'Project';
+			$parentElement = 'projet';
+			$parentObject = 'project';
+		}
 		elseif ($element == 'fichinter') {
 			$element='ficheinter';
 			$dir_output=$conf->$element->dir_output;
@@ -80,6 +90,10 @@ class FileUpload
 		elseif ($element == 'invoice_supplier') {
 			$pathname = 'fourn'; $filename='fournisseur.facture';
 			$dir_output=$conf->fournisseur->facture->dir_output;
+		}
+		elseif ($element == 'action') {
+			$pathname = 'comm/action'; $filename='actioncomm';
+			$dir_output=$conf->agenda->dir_output;
 		} else {
 			$dir_output=$conf->$element->dir_output;
 		}
@@ -97,11 +111,23 @@ class FileUpload
 		$object = new $classname($db);
 
 		$object->fetch($fk_element);
-		$object->fetch_thirdparty();
+		if (!empty($parentForeignKey)) {
+			dol_include_once('/'.$parentElement.'/class/'.$parentObject.'.class.php');
+			$parent = new $parentClass($db);
+			$parent->fetch($object->$parentForeignKey);
+			if (!empty($parent->socid)) {
+				$parent->fetch_thirdparty();
+			}
+			$object->$parentObject = dol_clone($parent);
+		} else {
+			$object->fetch_thirdparty();
+		}
 
 		$object_ref = dol_sanitizeFileName($object->ref);
 		if ($element == 'invoice_supplier') {
 			$object_ref = get_exdir($object->id, 2) . $object_ref;
+		} else if ($element == 'project_task') {
+			$object_ref = $object->project->ref . '/' . $object_ref;
 		}
 
 		$this->options = array(
diff --git a/htdocs/projet/class/task.class.php b/htdocs/projet/class/task.class.php
index f28e5d27e6d3f629a91b7268b05d52d9de09c6c8..12571aad64ae516e3bc76ff9d95cce7f5f202391 100644
--- a/htdocs/projet/class/task.class.php
+++ b/htdocs/projet/class/task.class.php
@@ -171,6 +171,7 @@ class Task extends CommonObject
         $sql.= " t.label,";
         $sql.= " t.description,";
         $sql.= " t.duration_effective,";
+        $sql.= " t.datec,";
         $sql.= " t.dateo,";
         $sql.= " t.datee,";
         $sql.= " t.fk_user_creat,";
diff --git a/htdocs/projet/tasks/document.php b/htdocs/projet/tasks/document.php
index 5d42a44d54b67ee32b2b201f5e238a589575cbfb..90adc2925c22fccf52537cf8be86ce9ec471fa33 100644
--- a/htdocs/projet/tasks/document.php
+++ b/htdocs/projet/tasks/document.php
@@ -93,7 +93,11 @@ if ($id > 0 || ! empty($ref))
 	{
 		$projectstatic->fetch($object->fk_project);
 
-		if (! empty($projectstatic->socid)) $projectstatic->societe->fetch($projectstatic->socid);
+		if (! empty($projectstatic->socid)) {
+			$projectstatic->fetch_thirdparty();
+		}
+
+		$object->project = dol_clone($projectstatic);
 
 		$upload_dir = $conf->projet->dir_output.'/'.dol_sanitizeFileName($projectstatic->ref).'/'.dol_sanitizeFileName($object->ref);
 	}
@@ -114,7 +118,7 @@ if ($action=='delete')
 {
     $langs->load("other");
 	$file = $upload_dir . '/' . GETPOST('urlfile');	// Do not use urldecode here ($_GET and $_REQUEST are already decoded by PHP).
-	$ret=dol_delete_file($file);
+	$ret=dol_delete_file($file,0,0,0,$object);
 	if ($ret) setEventMessage($langs->trans("FileWasRemoved", GETPOST('urlfile')));
 	else setEventMessage($langs->trans("ErrorFailToDeleteFile", GETPOST('urlfile')), 'errors');
     header('Location: '.$_SERVER["PHP_SELF"].'?id='.$id);