diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php index 00c927bad99..168beb73b43 100644 --- a/htdocs/compta/facture.php +++ b/htdocs/compta/facture.php @@ -865,6 +865,16 @@ else if ($action == 'add' && $user->rights->facture->creer) // Possibility to add external linked objects with hooks $object->linked_objects [$object->origin] = $object->origin_id; + // link with order if it is a shipping invoice + if ($object->origin == 'shipping') + { + require_once DOL_DOCUMENT_ROOT . '/expedition/class/expedition.class.php'; + $exp = new Expedition($db); + $exp->fetch($object->origin_id); + $exp->fetchObjectLinked(); + if (count ($exp->linkedObjectsIds['commande']) > 0) $object->linked_objects['commande'] = $exp->linkedObjectsIds['commande'][0]; + } + if (is_array($_POST['other_linked_objects']) && ! empty($_POST['other_linked_objects'])) { $object->linked_objects = array_merge($object->linked_objects, $_POST['other_linked_objects']); }