From 46cc35faff3896475334ad90046e10900aec9c2e Mon Sep 17 00:00:00 2001 From: William Mead Date: Wed, 17 Dec 2025 09:07:32 +0100 Subject: [PATCH 1/2] Added warehouse document generation --- htdocs/api/class/api_documents.class.php | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/htdocs/api/class/api_documents.class.php b/htdocs/api/class/api_documents.class.php index 4d6e0662746..30971e6368f 100644 --- a/htdocs/api/class/api_documents.class.php +++ b/htdocs/api/class/api_documents.class.php @@ -324,6 +324,22 @@ class Documents extends DolibarrApi $templateused = $doctemplate ? $doctemplate : $tmpobject->model_pdf; $result = $tmpobject->generateDocument($templateused, $outputlangs, $hidedetails, $hidedesc, $hideref); + if ($result <= 0) { + throw new RestException(500, 'Error generating document missing doctemplate parameter'); + } + } elseif ($modulepart == 'stock') { + require_once DOL_DOCUMENT_ROOT . '/product/stock/class/entrepot.class.php'; + + $tmpobject = new Entrepot($this->db); + $result = $tmpobject->fetch(0, preg_replace('/\.[^\.]+$/', '', basename($original_file))); + + if (!$result) { + throw new RestException(404, 'Warehouse not found'); + } + + $templateused = $doctemplate ? $doctemplate : $tmpobject->model_pdf; + $result = $tmpobject->generateDocument($templateused, $outputlangs, $hidedetails, $hidedesc, $hideref); + if ($result <= 0) { throw new RestException(500, 'Error generating document missing doctemplate parameter'); } From c0503d1e89f88e6216c892353452c12d9127fcd1 Mon Sep 17 00:00:00 2001 From: William Mead Date: Wed, 17 Dec 2025 09:08:00 +0100 Subject: [PATCH 2/2] Updated modulepart check --- htdocs/api/class/api_documents.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/api/class/api_documents.class.php b/htdocs/api/class/api_documents.class.php index 30971e6368f..f1b68e839c1 100644 --- a/htdocs/api/class/api_documents.class.php +++ b/htdocs/api/class/api_documents.class.php @@ -327,7 +327,7 @@ class Documents extends DolibarrApi if ($result <= 0) { throw new RestException(500, 'Error generating document missing doctemplate parameter'); } - } elseif ($modulepart == 'stock') { + } elseif ($modulepart == 'stock' || $modulepart == 'entrepot') { require_once DOL_DOCUMENT_ROOT . '/product/stock/class/entrepot.class.php'; $tmpobject = new Entrepot($this->db);