From 0d609ee734b784e6d9981d4420cbf37ca835fb02 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 16 Apr 2026 17:35:43 +0200 Subject: [PATCH] Fix generate_pdf and auto_validate == 2 must be different. --- htdocs/compta/facture/class/facture-rec.class.php | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/htdocs/compta/facture/class/facture-rec.class.php b/htdocs/compta/facture/class/facture-rec.class.php index 418c6b5dd82..61c6a20747b 100644 --- a/htdocs/compta/facture/class/facture-rec.class.php +++ b/htdocs/compta/facture/class/facture-rec.class.php @@ -1500,7 +1500,7 @@ class FactureRec extends CommonInvoice $errorforinvoice++; } } - if (!$errorforinvoice && $facturerec->generate_pdf) { + if (!$errorforinvoice && ($facturerec->generate_pdf || $facturerec->auto_validate == 2)) { // ->generate_pdf is 1 by default (can be edited if INVOICE_REC_CAN_DISABLE_DOCUMENT_FILE_GENERATION is set to 1) // We reload the object in order to have all necessary data (like date_lim_reglement) $facture->fetch($facture->id); $outputlangs = $langs; @@ -1512,11 +1512,14 @@ class FactureRec extends CommonInvoice $outputlangs->loadLangs(array('main', 'bills')); } } - $result = $facture->generateDocument($facturerec->model_pdf, $outputlangs); - if ($result <= 0) { - $this->setErrorsFromObject($facture); - $error++; - $errorforinvoice++; + + if ($facturerec->generate_pdf) { + $result = $facture->generateDocument($facturerec->model_pdf, $outputlangs); + if ($result <= 0) { + $this->setErrorsFromObject($facture); + $error++; + $errorforinvoice++; + } } // Auto sending of the invoice