diff --git a/htdocs/fourn/class/fournisseur.facture.class.php b/htdocs/fourn/class/fournisseur.facture.class.php index acad0e9abd2..686b3ef6a67 100644 --- a/htdocs/fourn/class/fournisseur.facture.class.php +++ b/htdocs/fourn/class/fournisseur.facture.class.php @@ -3210,7 +3210,7 @@ class FactureFournisseur extends CommonInvoice */ public function createFromClone(User $user, $fromid, $invertdetail = 0) { - global $conf, $langs; + global $conf, $langs, $hookmanager; $error = 0; @@ -3220,6 +3220,8 @@ class FactureFournisseur extends CommonInvoice // Load source object $object->fetch($fromid); + $objFrom = clone $object; + $object->id = 0; $object->statut = self::STATUS_DRAFT; // For backward compatibility $object->status = self::STATUS_DRAFT; @@ -3263,6 +3265,16 @@ class FactureFournisseur extends CommonInvoice } if (!$error) { + // Hook of thirdparty module + if (is_object($hookmanager)) { + $parameters = array('objFrom'=>$objFrom); + $action = ''; + $reshook = $hookmanager->executeHooks('createFrom', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks + if ($reshook < 0) { + $this->setErrorsFromObject($hookmanager); + $error++; + } + } } unset($object->context['createfromclone']);