check batch on receptions->addline when module is enabled

This commit is contained in:
Thomas Negre 2022-07-08 15:30:31 +02:00
parent e60c6ae96d
commit 56ea6989cf

View File

@ -752,6 +752,23 @@ class Reception extends CommonObject
}
}
// Check batch is set
$product = new Product($this->db);
$product->fetch($fk_product);
if (!empty($conf->productbatch->enabled)) {
$langs->load("errors");
if (!empty($product->status_batch) && empty($batch)) {
$this->error = $langs->trans('ErrorProductNeedBatchNumber', $product->ref);
setEventMessages($this->error, $this->errors, 'errors');
return -1;
} elseif (empty($product->status_batch) && !empty($batch)) {
$this->error = $langs->trans('ErrorProductDoesNotNeedBatchNumber', $product->ref);
setEventMessages($this->error, $this->errors, 'errors');
return -1;
}
}
unset ($product);
// extrafields
$line->array_options = $supplierorderline->array_options;
if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && is_array($array_options) && count($array_options) > 0) {