From 56ea6989cf8a67557d4abaa551f66fcb5b65eaf3 Mon Sep 17 00:00:00 2001 From: Thomas Negre Date: Fri, 8 Jul 2022 15:30:31 +0200 Subject: [PATCH 1/3] check batch on receptions->addline when module is enabled --- htdocs/reception/class/reception.class.php | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/htdocs/reception/class/reception.class.php b/htdocs/reception/class/reception.class.php index 0be0ea7ba37..9f8fb616582 100644 --- a/htdocs/reception/class/reception.class.php +++ b/htdocs/reception/class/reception.class.php @@ -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) { From f042a62a1c8e3604f87ce82c72d668d00dbf135c Mon Sep 17 00:00:00 2001 From: Thomas Negre Date: Fri, 8 Jul 2022 15:47:13 +0200 Subject: [PATCH 2/3] remove overkill setEventMessage() --- htdocs/reception/class/reception.class.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/htdocs/reception/class/reception.class.php b/htdocs/reception/class/reception.class.php index 9f8fb616582..3cf5220edbb 100644 --- a/htdocs/reception/class/reception.class.php +++ b/htdocs/reception/class/reception.class.php @@ -759,11 +759,9 @@ class Reception extends CommonObject $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; } } From c0d3aaf445763473bbc002143f177fc16127f506 Mon Sep 17 00:00:00 2001 From: Thomas Negre Date: Fri, 8 Jul 2022 15:53:41 +0200 Subject: [PATCH 3/3] stickler fix --- htdocs/reception/class/reception.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/reception/class/reception.class.php b/htdocs/reception/class/reception.class.php index 3cf5220edbb..53acd077d2b 100644 --- a/htdocs/reception/class/reception.class.php +++ b/htdocs/reception/class/reception.class.php @@ -765,7 +765,7 @@ class Reception extends CommonObject return -1; } } - unset ($product); + unset($product); // extrafields $line->array_options = $supplierorderline->array_options;