diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php index 2ce51ad3afd..923ee04036a 100644 --- a/htdocs/compta/facture.php +++ b/htdocs/compta/facture.php @@ -74,6 +74,7 @@ $ref = GETPOST('ref', 'alpha'); $socid = GETPOST('socid', 'int'); $action = GETPOST('action', 'alpha'); $confirm = GETPOST('confirm', 'alpha'); +$cancel = GETPOST('cancel', 'alpha'); $lineid = GETPOST('lineid', 'int'); $userid = GETPOST('userid', 'int'); $search_ref = GETPOST('sf_ref') ? GETPOST('sf_ref', 'alpha') : GETPOST('search_ref', 'alpha'); @@ -124,12 +125,22 @@ if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'e if (empty($reshook)) { + if ($cancel) $action=''; + include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, not includ_once include DOL_DOCUMENT_ROOT.'/core/actions_dellink.inc.php'; // Must be include, not include_once include DOL_DOCUMENT_ROOT.'/core/actions_lineupdown.inc.php'; // Must be include, not include_once + // Link invoice to order + if (GETPOST('linkedOrder') && empty($cancel) && $id > 0) + { + $object->fetch($id); + $object->fetch_thirdparty(); + $result = $object->add_object_linked('commande', GETPOST('linkedOrder')); + } + // Action clone object if ($action == 'confirm_clone' && $confirm == 'yes' && $user->rights->facture->creer) { // if (1 == 0 && empty($_REQUEST["clone_content"]) && empty($_REQUEST["clone_receivers"])) { @@ -1692,13 +1703,6 @@ if (empty($reshook)) exit(); } - // Link invoice to order - if (GETPOST('linkedOrder')) { - $object->fetch($id); - $object->fetch_thirdparty(); - $result = $object->add_object_linked('commande', GETPOST('linkedOrder')); - } - /* * Send mail diff --git a/htdocs/fourn/facture/card.php b/htdocs/fourn/facture/card.php index ac630989ba0..518f09b5316 100644 --- a/htdocs/fourn/facture/card.php +++ b/htdocs/fourn/facture/card.php @@ -110,6 +110,14 @@ if (empty($reshook)) include DOL_DOCUMENT_ROOT.'/core/actions_lineupdown.inc.php'; // Must be include, not include_once + // Link invoice to order + if (GETPOST('linkedOrder') && empty($cancel) && $id > 0) + { + $object->fetch($id); + $object->fetch_thirdparty(); + $result = $object->add_object_linked('order_supplier', GETPOST('linkedOrder')); + } + // Action clone object if ($action == 'confirm_clone' && $confirm == 'yes') { @@ -894,13 +902,6 @@ if (empty($reshook)) } } - // Link invoice to order - if (GETPOST('linkedOrder')) { - $object->fetch($id); - $object->fetch_thirdparty(); - $result = $object->add_object_linked('order_supplier', GETPOST('linkedOrder')); - } - // Add file in email form if (GETPOST('addfile')) {