diff --git a/htdocs/adherents/document.php b/htdocs/adherents/document.php
index 7860d36c9fbdacc223bb1f2e50a212f98b694c69..47fbebbf976d6abfc2da8c9df59450b9a9fcdee3 100644
--- a/htdocs/adherents/document.php
+++ b/htdocs/adherents/document.php
@@ -158,6 +158,7 @@ if ($id > 0)
 
 		$modulepart = 'member';
 		$permission = $user->rights->adherent->creer;
+		$permtoedit = $user->rights->adherent->creer;
 		$param = '&id=' . $object->id;
 		include_once DOL_DOCUMENT_ROOT . '/core/tpl/document_actions_post_headers.tpl.php';
 		print "<br><br>";
diff --git a/htdocs/comm/propal/document.php b/htdocs/comm/propal/document.php
index 668b093e7db07c1a761748680dffabfae1f14887..289ba272b8c554364686f82950b2cb2f8e0ac810 100644
--- a/htdocs/comm/propal/document.php
+++ b/htdocs/comm/propal/document.php
@@ -133,6 +133,7 @@ if ($object->id > 0)
 
 	$modulepart = 'propal';
 	$permission = $user->rights->propal->creer;
+	$permtoedit = $user->rights->propal->creer;
 	$param = '&id=' . $object->id;
 	include_once DOL_DOCUMENT_ROOT . '/core/tpl/document_actions_post_headers.tpl.php';
 }
diff --git a/htdocs/commande/document.php b/htdocs/commande/document.php
index 6b96940df98836f05671aeaa969e9c2cc2de3cc6..a05a6e0061de8d56b6dee9a6ae11af0e3fb35c92 100644
--- a/htdocs/commande/document.php
+++ b/htdocs/commande/document.php
@@ -121,6 +121,7 @@ if ($id > 0 || ! empty($ref))
 
 		$modulepart = 'commande';
 		$permission = $user->rights->commande->creer;
+		$permtoedit = $user->rights->commande->creer;
 		$param = '&id=' . $object->id;
 		include_once DOL_DOCUMENT_ROOT . '/core/tpl/document_actions_post_headers.tpl.php';
 	}
diff --git a/htdocs/compta/bank/document.php b/htdocs/compta/bank/document.php
index a014bdc5d60f698195c301a1ce2d974ad42321d4..4c2182bb1e8279ef593abb7c14ca6d945e240a71 100644
--- a/htdocs/compta/bank/document.php
+++ b/htdocs/compta/bank/document.php
@@ -217,6 +217,7 @@ if ($id > 0 || !empty($ref)) {
 }
 else {
     Header('Location: index.php');
+    exit;
 }
 
 
diff --git a/htdocs/compta/facture/document.php b/htdocs/compta/facture/document.php
index 9a15b7875d8b5fb7332ae8d84914ea532debed9d..246e55957798d05cca535051e7dbf0739dfbedaf 100644
--- a/htdocs/compta/facture/document.php
+++ b/htdocs/compta/facture/document.php
@@ -149,6 +149,7 @@ if ($id > 0 || ! empty($ref))
 
 		$modulepart = 'facture';
 		$permission = $user->rights->facture->creer;
+		$permtoedit = $user->rights->facture->creer;
 		$param = '&id=' . $object->id;
 		include_once DOL_DOCUMENT_ROOT . '/core/tpl/document_actions_post_headers.tpl.php';
 
diff --git a/htdocs/contact/document.php b/htdocs/contact/document.php
index 988dfc28dad42b8731492d65e3f7b0752d000fc8..8c79dfd15801e37c29ac539a9e87035fe132aa60 100644
--- a/htdocs/contact/document.php
+++ b/htdocs/contact/document.php
@@ -138,6 +138,7 @@ if ($object->id)
     
     $modulepart = 'contact';
     $permission = $user->rights->societe->contact->creer;
+    $permtoedit = $user->rights->societe->contact->creer;
     $param = '&id=' . $object->id;
     include DOL_DOCUMENT_ROOT . '/core/tpl/document_actions_post_headers.tpl.php';
 } else {
diff --git a/htdocs/contrat/document.php b/htdocs/contrat/document.php
index 024cf561fb58cbdc1615c6c4e6761933ea2faa5c..ef7e73ad4c8b7c556cffb34828a3235d967b6fc8 100644
--- a/htdocs/contrat/document.php
+++ b/htdocs/contrat/document.php
@@ -124,6 +124,7 @@ if ($object->id)
 
     $modulepart = 'contract';
     $permission = $user->rights->contrat->creer;
+    $permtoedit = $user->rights->contrat->creer;
     $param = '&id=' . $object->id;
     include_once DOL_DOCUMENT_ROOT . '/core/tpl/document_actions_post_headers.tpl.php';
 
diff --git a/htdocs/don/document.php b/htdocs/don/document.php
index 4992e5dbbc8d49c4e416d62371e16c2da0d5bea6..4c5ae99e2989dd5c761a6a28df32a61c7b3e9eab 100644
--- a/htdocs/don/document.php
+++ b/htdocs/don/document.php
@@ -122,6 +122,7 @@ if ($object->id)
 
     $modulepart = 'don';
     $permission = $user->rights->don->lire;
+    $permtoedit = $user->rights->don->creer;
     $param = '&id=' . $object->id;
     include_once DOL_DOCUMENT_ROOT . '/core/tpl/document_actions_post_headers.tpl.php';
 
diff --git a/htdocs/fichinter/document.php b/htdocs/fichinter/document.php
index 59a3bbf3c5d9fc1fcaf60fc988722991f7a42943..a0bc97a17afa5072e7fc28129fe6643547fe03dc 100644
--- a/htdocs/fichinter/document.php
+++ b/htdocs/fichinter/document.php
@@ -121,6 +121,7 @@ if ($object->id)
 
     $modulepart = 'ficheinter';
     $permission = $user->rights->ficheinter->creer;
+    $permtoedit = $user->rights->ficheinter->creer;
     $param = '&id=' . $object->id;
     include_once DOL_DOCUMENT_ROOT . '/core/tpl/document_actions_post_headers.tpl.php';
 
diff --git a/htdocs/fourn/commande/document.php b/htdocs/fourn/commande/document.php
index cd6542a28106a93f642f5420227e1a9ab0ce1de3..35594d0f01224e337458bce458bf372b93303f5b 100644
--- a/htdocs/fourn/commande/document.php
+++ b/htdocs/fourn/commande/document.php
@@ -161,6 +161,7 @@ if ($object->id > 0)
 
 	$modulepart = 'commande_fournisseur';
 	$permission = $user->rights->fournisseur->commande->creer;
+	$permtoedit = $user->rights->fournisseur->commande->creer;
 	$param = '&id=' . $object->id;
 	include_once DOL_DOCUMENT_ROOT . '/core/tpl/document_actions_post_headers.tpl.php';
 
diff --git a/htdocs/fourn/facture/document.php b/htdocs/fourn/facture/document.php
index 3ca1c2d05faa7a6bbd8b5143be94914592a47bb3..c9a40f9b59004efef5ca4d156ae2a6f366dd6413 100644
--- a/htdocs/fourn/facture/document.php
+++ b/htdocs/fourn/facture/document.php
@@ -208,6 +208,7 @@ if ($object->id > 0)
 
 	$modulepart = 'facture_fournisseur';
 	$permission = $user->rights->fournisseur->facture->creer;
+	$permtoedit = $user->rights->fournisseur->facture->creer;
 	$param = '&facid=' . $object->id;
 	include_once DOL_DOCUMENT_ROOT . '/core/tpl/document_actions_post_headers.tpl.php';
 }
diff --git a/htdocs/holiday/document.php b/htdocs/holiday/document.php
index 4f45704a269ecea3b5d2defa312fff3858c83c1d..edc85ca0060aaee9f3054ae235716826ae9123a7 100644
--- a/htdocs/holiday/document.php
+++ b/htdocs/holiday/document.php
@@ -222,6 +222,7 @@ if ($object->id)
 
     $modulepart = 'holiday';
     $permission = $user->rights->holiday->write;
+    $permtoedit = $user->rights->holiday->write;
     $param = '&id=' . $object->id;
     include_once DOL_DOCUMENT_ROOT . '/core/tpl/document_actions_post_headers.tpl.php';
 }
diff --git a/htdocs/loan/document.php b/htdocs/loan/document.php
index 7463da4a1906518cefcae418b99db141e518e8a3..732d8193638a8a40ec9ca69638ebf940d77ed912 100644
--- a/htdocs/loan/document.php
+++ b/htdocs/loan/document.php
@@ -157,6 +157,7 @@ if ($object->id)
 
     $modulepart = 'loan';
     $permission = $user->rights->loan->write;
+    $permtoedit = $user->rights->loan->write;
     $param = '&id=' . $object->id;
     include_once DOL_DOCUMENT_ROOT . '/core/tpl/document_actions_post_headers.tpl.php';
 }
diff --git a/htdocs/projet/document.php b/htdocs/projet/document.php
index d59dec0dc4a88ec2fe9ccd45c3892661a76ee5c8..5485834ea26ba934bcd7fb56520da5f57b7c7f1d 100644
--- a/htdocs/projet/document.php
+++ b/htdocs/projet/document.php
@@ -148,6 +148,7 @@ if ($object->id > 0)
 
 	$modulepart = 'project';
 	$permission = ($userWrite > 0);
+	$permtoedit = ($userWrite > 0);
 	include_once DOL_DOCUMENT_ROOT . '/core/tpl/document_actions_post_headers.tpl.php';
 
 }
diff --git a/htdocs/projet/tasks/document.php b/htdocs/projet/tasks/document.php
index c9a69fc81a4ef9b851a52f08a59ca4b42e69fe12..370ee117169e6ae1761424589ddf658325338e94 100644
--- a/htdocs/projet/tasks/document.php
+++ b/htdocs/projet/tasks/document.php
@@ -242,6 +242,7 @@ if ($object->id > 0)
 	if ($withproject) $param .= '&withproject=1';
 	$modulepart = 'project_task';
 	$permission = $user->rights->projet->creer;
+	$permtoedit = $user->rights->projet->creer;
 	$relativepathwithnofile=dol_sanitizeFileName($projectstatic->ref).'/'.dol_sanitizeFileName($object->ref).'/';
 	include_once DOL_DOCUMENT_ROOT . '/core/tpl/document_actions_post_headers.tpl.php';
 }
diff --git a/htdocs/societe/document.php b/htdocs/societe/document.php
index e64c9c49656b7bcf9d8ce3ab560a7743c7459085..d83822c2cd739a7532d66bcdbc16b30074a0fa13 100644
--- a/htdocs/societe/document.php
+++ b/htdocs/societe/document.php
@@ -156,6 +156,7 @@ if ($object->id)
 
 	$modulepart = 'societe';
 	$permission = $user->rights->societe->creer;
+	$permtoedit = $user->rights->societe->creer;
 	$param = '&id=' . $object->id;
 	include_once DOL_DOCUMENT_ROOT . '/core/tpl/document_actions_post_headers.tpl.php';
 }
diff --git a/htdocs/supplier_proposal/document.php b/htdocs/supplier_proposal/document.php
index 77844225720469bfdea165a7924bf5ef461da868..d8c51a4515243f06e9a9337289257d462d305b68 100644
--- a/htdocs/supplier_proposal/document.php
+++ b/htdocs/supplier_proposal/document.php
@@ -115,6 +115,7 @@ if ($object->id > 0)
 
 	$modulepart = 'supplier_proposal';
 	$permission = $user->rights->supplier_proposal->creer;
+	$permtoedit = $user->rights->supplier_proposal->creer;
 	$param = '&id=' . $object->id;
 	include_once DOL_DOCUMENT_ROOT . '/core/tpl/document_actions_post_headers.tpl.php';
 }