Merge pull request #36682 from W1W1-M/new-document-api-warehouse

NEW document API stock warehouse
This commit is contained in:
Laurent Destailleur 2025-12-17 13:23:56 +01:00 committed by GitHub
commit 9ec8d30692
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 24 additions and 0 deletions

View file

@ -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.');
}

View file

@ -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)) {