Merge pull request #20994 from fappels/16_fix_lot_document_management

FIX: Product lot document management should not use batch but ref (is lot id)
This commit is contained in:
Laurent Destailleur 2022-05-24 21:39:49 +02:00 committed by GitHub
commit 13944ea2c0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 2 deletions

View File

@ -28,6 +28,7 @@ require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/product.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
require_once DOL_DOCUMENT_ROOT.'/product/stock/class/productlot.class.php';
@ -90,7 +91,13 @@ if ($id || $ref) {
$batch = $tmp[1];
}
$object->fetch($id, $productid, $batch);
$object->ref = $object->batch; // For document management ( it use $object->ref)
$object->ref = $object->batch; // Old system for document management ( it uses $object->ref)
$upload_dir = $conf->productbatch->multidir_output[$object->entity].'/'.get_exdir(0, 0, 0, 1, $object, $modulepart);
$filearray = dol_dir_list($upload_dir, "files");
if (empty($filearray)) {
// If no files linked yet, use new system on lot id. (Batch is not unique and can be same on different product)
$object->fetch($id, $productid, $batch);
}
}
// Initialize technical object to manage hooks of modules. Note that conf->hooks_modules contains array array

View File

@ -83,10 +83,16 @@ if ($id || $ref) {
$batch = $tmp[1];
}
$object->fetch($id, $productid, $batch);
$object->ref = $object->batch; // For document management ( it use $object->ref)
$object->ref = $object->batch; // Old system for document management ( it uses $object->ref)
if (!empty($conf->productbatch->enabled)) {
$upload_dir = $conf->productbatch->multidir_output[$object->entity].'/'.get_exdir(0, 0, 0, 1, $object, $modulepart);
$filearray = dol_dir_list($upload_dir, "files");
if (empty($filearray)) {
// If no files linked yet, use new system on lot id. (Batch is not unique and can be same on different product)
$object->fetch($id, $productid, $batch);
$upload_dir = $conf->productbatch->multidir_output[$object->entity].'/'.get_exdir(0, 0, 0, 1, $object, $modulepart);
}
}
}