Add hook createFrom to supplier invoices (#37862)

This commit is contained in:
ThomasNgr-OpenDSI 2026-04-14 19:47:14 +02:00 committed by GitHub
parent c19ffedd26
commit 44b41d30fb
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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']);