This commit is contained in:
Frédéric FRANCE 2022-12-12 15:19:08 +01:00
parent 22bf6cc5a6
commit d5fbab8688
2 changed files with 21 additions and 2 deletions

View File

@ -143,6 +143,15 @@ class mod_lot_advanced extends ModeleNumRefBatch
// We get cursor rule
$mask = getDolGlobalString('LOT_ADVANCED_MASK');
$filter = '';
if (getDolGlobalString('PRODUCTBATCH_LOT_USE_PRODUCT_MASKS') && !empty($object->fk_product)) {
$product = new Product($db);
$res = $product->fetch($object->fk_product);
if ($res > 0 && !empty($product->batch_mask)) {
$mask = $product->batch_mask;
$filter = '';
}
}
if (!$mask) {
$this->error = 'NotConfigured';
@ -151,7 +160,7 @@ class mod_lot_advanced extends ModeleNumRefBatch
$date = dol_now();
$numFinal = get_next_value($db, $mask, 'product_lot', 'batch', '', null, $date);
$numFinal = get_next_value($db, $mask, 'product_lot', 'batch', $filter, null, $date);
return $numFinal;
}

View File

@ -144,6 +144,16 @@ class mod_sn_advanced extends ModeleNumRefBatch
// We get cursor rule
$mask = getDolGlobalString('SN_ADVANCED_MASK');
$filter = '';
if (getDolGlobalString('PRODUCTBATCH_SN_USE_PRODUCT_MASKS') && !empty($object->fk_product)) {
$product = new Product($db);
$res = $product->fetch($object->fk_product);
if ($res > 0 && !empty($product->batch_mask)) {
$mask = $product->batch_mask;
$filter = '';
}
}
if (!$mask) {
$this->error = 'NotConfigured';
return 0;
@ -151,7 +161,7 @@ class mod_sn_advanced extends ModeleNumRefBatch
$date = dol_now();
$numFinal = get_next_value($db, $mask, 'product_lot', 'batch', '', null, $date);
$numFinal = get_next_value($db, $mask, 'product_lot', 'batch', $filter, null, $date);
return $numFinal;
}