Add hook createFrom to supplier invoices (#37862)
This commit is contained in:
parent
c19ffedd26
commit
44b41d30fb
1 changed files with 13 additions and 1 deletions
|
|
@ -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']);
|
||||
|
|
|
|||
Loading…
Reference in a new issue