From 5bae9db0a82292d2eb2c01268cce2b738bc488e3 Mon Sep 17 00:00:00 2001 From: kamel Date: Tue, 2 Jun 2020 17:29:55 +0200 Subject: [PATCH 1/2] FIX: Fix detect distached product and set to received completely when the supplier order have services (support STOCK_SUPPORTS_SERVICES) --- htdocs/fourn/class/fournisseur.commande.class.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index 092c3df8dc2..66788cdb126 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -3063,6 +3063,7 @@ class CommandeFournisseur extends CommonOrder { if (is_array($supplierorderdispatch->lines) && count($supplierorderdispatch->lines)>0) { + require_once DOL_DOCUMENT_ROOT.'/htdocs/product/class/product.class.php'; $date_liv = dol_now(); // Build array with quantity deliverd by product @@ -3070,7 +3071,11 @@ class CommandeFournisseur extends CommonOrder $qtydelivered[$line->fk_product]+=$line->qty; } foreach($this->lines as $line) { - $qtywished[$line->fk_product]+=$line->qty; + if ($line->product_type == Product::TYPE_PRODUCT || + ($line->product_type == Product::TYPE_SERVICE && !empty($conf->global->STOCK_SUPPORTS_SERVICES)) + ) { + $qtywished[$line->fk_product] += $line->qty; + } } //Compare array $diff_array=array_diff_assoc($qtydelivered, $qtywished); // Warning: $diff_array is done only on common keys. From 8dfe39258b856e91ee5d3b47c2bf230f323069f3 Mon Sep 17 00:00:00 2001 From: Florian Mortgat Date: Wed, 27 Jan 2021 23:46:09 +0100 Subject: [PATCH 2/2] FIX 11.0 - when a mandatory extrafield of type sellist contains '0' it should be considered empty and trigger an error message upon insertion --- htdocs/core/class/commonobject.class.php | 1 + htdocs/core/class/extrafields.class.php | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 1ff633f46ce..f2c61bc86a3 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -5238,6 +5238,7 @@ abstract class CommonObject $mandatorypb = false; if ($attributeType == 'link' && $this->array_options[$key] == '-1') $mandatorypb = true; if ($this->array_options[$key] === '') $mandatorypb = true; + if ($attributeType == 'sellist' && $this->array_options[$key] == '0') $mandatorypb = true; if ($mandatorypb) { dol_syslog("Mandatory extra field ".$key." is empty"); diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php index 57e2bf4284a..ed85a328edc 100644 --- a/htdocs/core/class/extrafields.class.php +++ b/htdocs/core/class/extrafields.class.php @@ -2060,9 +2060,12 @@ class ExtraFields if ($this->attributes[$object->table_element]['required'][$key]) // Value is required { - // Check if empty without using GETPOST, value can be alpha, int, array, etc... + // check if functionally empty without using GETPOST (depending on the type of extrafield, a + // technically non-empty value may be treated as empty functionally). + // value can be alpha, int, array, etc... if ((!is_array($_POST["options_".$key]) && empty($_POST["options_".$key]) && $this->attributes[$object->table_element]['type'][$key] != 'select' && $_POST["options_".$key] != '0') || (!is_array($_POST["options_".$key]) && empty($_POST["options_".$key]) && $this->attributes[$object->table_element]['type'][$key] == 'select') + || (!is_array($_POST["options_".$key]) && isset($_POST["options_".$key]) && $this->attributes[$object->table_element]['type'][$key] == 'sellist' && $_POST['options_' . $key] == '0') || (is_array($_POST["options_".$key]) && empty($_POST["options_".$key]))) { //print 'ccc'.$value.'-'.$this->attributes[$object->table_element]['required'][$key];