From 7ab079d0f0ca1795b2943164208d76898b2f6cb1 Mon Sep 17 00:00:00 2001 From: William Mead Date: Wed, 17 Dec 2025 08:39:46 +0100 Subject: [PATCH 1/2] Added stock warehouse documents --- htdocs/api/class/api_documents.class.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/htdocs/api/class/api_documents.class.php b/htdocs/api/class/api_documents.class.php index 4d6e0662746..ca640756e32 100644 --- a/htdocs/api/class/api_documents.class.php +++ b/htdocs/api/class/api_documents.class.php @@ -709,6 +709,19 @@ class Documents extends DolibarrApi throw new RestException(404, 'Contact not found'); } $upload_dir = $conf->societe->multidir_output[$object->entity ?? $conf->entity] . "/contact/" . get_exdir(0, 0, 0, 1, $object, 'contact'); + } elseif ($modulepart == 'stock') { + require_once DOL_DOCUMENT_ROOT.'/product/stock/class/entrepot.class.php'; + + if (!DolibarrApiAccess::$user->hasRight('stock', 'lire')) { + throw new RestException(403); + } + + $object = new Entrepot($this->db); + $result = $object->fetch($id, $ref); + if (!$result) { + throw new RestException(404, 'Warehouse not found'); + } + $upload_dir = $conf->stock->multidir_output[$object->entity ?? $conf->entity].'/'.get_exdir(0, 0, 0, 1, $object, 'stock'); } else { throw new RestException(500, 'Modulepart '.$modulepart.' not implemented yet.'); } From 969b4e68d4603bfa3e0a4b53d808c4b89b606a02 Mon Sep 17 00:00:00 2001 From: William Mead Date: Wed, 17 Dec 2025 08:58:24 +0100 Subject: [PATCH 2/2] Added warehouse document download --- htdocs/core/lib/files.lib.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/htdocs/core/lib/files.lib.php b/htdocs/core/lib/files.lib.php index 60fae8a9443..130c9542b7e 100644 --- a/htdocs/core/lib/files.lib.php +++ b/htdocs/core/lib/files.lib.php @@ -3565,6 +3565,17 @@ function dol_check_secure_access_document($modulepart, $original_file, $entity, if (isModEnabled('stock')) { $original_file = $conf->stock->multidir_output[$entity].'/movement/'.$original_file; } + } elseif ($modulepart == 'entrepot') { + // Wrapping for stock warehouse + if (empty($entity) || empty($conf->stock->multidir_output[$entity])) { + return array('accessallowed' => 0, 'error' => 'Value entity must be provided'); + } + if (($fuser->hasRight('stock', $lire) || $fuser->hasRight('stock', 'movement', $lire) || $fuser->hasRight('stock', 'mouvement', $lire)) || preg_match('/^specimen/i', $original_file)) { + $accessallowed = 1; + } + if (isModEnabled('stock')) { + $original_file = $conf->stock->multidir_output[$entity].'/'.$original_file; + } } elseif ($modulepart == 'contract' && !empty($conf->contract->multidir_output[$entity])) { // Wrapping pour les contrats if ($fuser->hasRight('contrat', $lire) || preg_match('/^specimen/i', $original_file)) {