From eabafde91fac69002ee6c3a643a5ff2a9b6ada8e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 22 Oct 2022 13:41:25 +0200 Subject: [PATCH] FIX Do not generate the contract PDF if not default template defined --- htdocs/contrat/class/contrat.class.php | 19 +++++++++++-------- .../class/fournisseur.commande.class.php | 14 ++++++++------ 2 files changed, 19 insertions(+), 14 deletions(-) diff --git a/htdocs/contrat/class/contrat.class.php b/htdocs/contrat/class/contrat.class.php index 73d907a374e..5c72bf51c69 100644 --- a/htdocs/contrat/class/contrat.class.php +++ b/htdocs/contrat/class/contrat.class.php @@ -2441,18 +2441,15 @@ class Contrat extends CommonObject * @param int $hidedetails Hide details of lines * @param int $hidedesc Hide description * @param int $hideref Hide ref - * @param null|array $moreparams Array to provide more information - * @return int 0 if KO, 1 if OK + * @param null|array $moreparams Array to provide more information + * @return int < 0 if KO, 0 = no doc generated, > 0 if OK */ public function generateDocument($modele, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0, $moreparams = null) { global $conf, $langs; - $langs->load("contracts"); - $outputlangs->load("products"); - if (!dol_strlen($modele)) { - $modele = 'strato'; + $modele = ''; // No doc template/generation by default if (!empty($this->model_pdf)) { $modele = $this->model_pdf; @@ -2463,9 +2460,15 @@ class Contrat extends CommonObject } } - $modelpath = "core/modules/contract/doc/"; + if (empty($modele)) { + return 0; + } else { + $langs->load("contracts"); + $outputlangs->load("products"); - return $this->commonGenerateDocument($modelpath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref, $moreparams); + $modelpath = "core/modules/contract/doc/"; + return $this->commonGenerateDocument($modelpath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref, $moreparams); + } } /** diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index 9e59dbceda6..1faa0b0c49c 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -3187,26 +3187,28 @@ class CommandeFournisseur extends CommonOrder * @param int $hidedesc Hide description * @param int $hideref Hide ref * @param null|array $moreparams Array to provide more information - * @return int 0 if KO, 1 if OK + * @return int < 0 if KO, 0 = no doc generated, > 0 if OK */ public function generateDocument($modele, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0, $moreparams = null) { global $conf, $langs; - $langs->load("suppliers"); - $outputlangs->load("products"); - if (!dol_strlen($modele)) { - $modele = ''; - if ($this->model_pdf) { + $modele = ''; // No doc template/generation by default + + if (!empty($this->model_pdf)) { $modele = $this->model_pdf; } elseif (!empty($conf->global->COMMANDE_SUPPLIER_ADDON_PDF)) { $modele = $conf->global->COMMANDE_SUPPLIER_ADDON_PDF; } } + if (empty($modele)) { return 0; } else { + $langs->load("suppliers"); + $outputlangs->load("products"); + $modelpath = "core/modules/supplier_order/doc/"; return $this->commonGenerateDocument($modelpath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref, $moreparams); }