From 1e12801e77281549f7a00e4e2234c86f62b401f8 Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Thu, 26 Sep 2024 08:21:27 +0200 Subject: [PATCH 1/4] fix: error return in mo creation when qty to consume is 0 --- htdocs/mrp/class/mo.class.php | 8 ++++++-- htdocs/mrp/mo_card.php | 1 + 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/htdocs/mrp/class/mo.class.php b/htdocs/mrp/class/mo.class.php index d5441945cfaa8..ebc66fdcaad7a 100644 --- a/htdocs/mrp/class/mo.class.php +++ b/htdocs/mrp/class/mo.class.php @@ -340,8 +340,10 @@ public function create(User $user, $notrigger = false) if (!$error) { $this->db->commit(); + return $idcreated; } else { $this->db->rollback(); + return -1; } return $idcreated; @@ -741,6 +743,7 @@ public function createProduction(User $user, $notrigger = true) $this->error = $moline->error; $this->errors = $moline->errors; dol_print_error($this->db, $moline->error, $moline->errors); + exit; } if ($this->fk_bom > 0) { // If a BOM is defined, we know what to consume. @@ -764,6 +767,7 @@ public function createProduction(User $user, $notrigger = true) if ($moline->qty <= 0) { $error++; $this->error = "BadValueForquantityToConsume"; + $this->errors[] = $this->error; break; } else { $moline->fk_product = $line->fk_product; @@ -779,7 +783,8 @@ public function createProduction(User $user, $notrigger = true) if ($resultline <= 0) { $error++; $this->error = $moline->error; - $this->errors = $moline->errors; + $this->errors[] = $moline->error; + $this->errors = array_merge($this->errors, $moline->errors); dol_print_error($this->db, $moline->error, $moline->errors); break; } @@ -789,7 +794,6 @@ public function createProduction(User $user, $notrigger = true) } } } - if (!$error) { $this->db->commit(); return 1; diff --git a/htdocs/mrp/mo_card.php b/htdocs/mrp/mo_card.php index e232f34aa1c5e..d6300fdb2b587 100644 --- a/htdocs/mrp/mo_card.php +++ b/htdocs/mrp/mo_card.php @@ -146,6 +146,7 @@ // Create MO with Childs if ($action == 'add' && empty($id) && !empty($TBomLineId)) { $noback = 1; + include DOL_DOCUMENT_ROOT.'/core/actions_addupdatedelete.inc.php'; $mo_parent = $object; From 83ac267a740bc0a8ff493052354643a4ab057ecc Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Thu, 26 Sep 2024 08:28:32 +0200 Subject: [PATCH 2/4] fix: error return in mo creation when qty to consume is 0 --- htdocs/langs/en_US/mrp.lang | 4 +--- htdocs/langs/fr_FR/mrp.lang | 8 +++----- htdocs/mrp/class/mo.class.php | 2 ++ 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/htdocs/langs/en_US/mrp.lang b/htdocs/langs/en_US/mrp.lang index 948bff0075724..992baea6da481 100644 --- a/htdocs/langs/en_US/mrp.lang +++ b/htdocs/langs/en_US/mrp.lang @@ -130,10 +130,8 @@ Manufacturing=Manufacturing Disassemble=Disassemble ProducedBy=Produced by QtyTot=Qty Total - QtyCantBeSplit= Quantity cannot be split NoRemainQtyToDispatch=No quantity remaining to divide - THMOperatorEstimatedHelp=Estimated cost of operator per hour. Will be used to estimate cost of a BOM using this workstation. THMMachineEstimatedHelp=Estimated cost of machine per hour. Will be used to estimate cost of a BOM using this workstation. - +BadValueForquantityToConsume=Quantity to consume for a material cannot be 0 or negative diff --git a/htdocs/langs/fr_FR/mrp.lang b/htdocs/langs/fr_FR/mrp.lang index a229b2a372328..4e7d8ed62014e 100644 --- a/htdocs/langs/fr_FR/mrp.lang +++ b/htdocs/langs/fr_FR/mrp.lang @@ -46,7 +46,7 @@ DateStartPlannedMo=Date de début prévue DateEndPlannedMo=Date de fin prévue KeepEmptyForAsap=Vide signifie 'Dès que possible' EstimatedDuration=Durée estimée -EstimatedDurationDesc=Durée de fabrication (ou décomposition) planifiée pour ce produit avec cette BOM +EstimatedDurationDesc=Durée de fabrication (ou décomposition) planifiée pour ce produit avec cette BOM ConfirmValidateBom=Voulez-vous vraiment valider la nomenclature (BOM) avec la référence %s (vous pourrez l'utiliser pour créer de nouveaux Ordres de Fabrication) ConfirmCloseBom=Voulez-vous vraiment annuler cette nomenclature (vous ne pourrez plus l'utiliser pour créer de nouveaux Ordres de Fabrication)? ConfirmReopenBom=Êtes-vous sûr de vouloir rouvrir cette nomenclature (vous pourrez l'utiliser pour créer de nouveaux Ordres de Fabrication) @@ -97,7 +97,7 @@ Workstation=Poste de travail Workstations=Postes de travail WorkstationsDescription=Gestion des postes de travail WorkstationSetup = Configuration du module Poste de travail -WorkstationSetupPage = Configuration du module Poste de travail +WorkstationSetupPage = Configuration du module Poste de travail WorkstationList=Liste des postes de travail WorkstationCreate=Ajouter un nouveau poste de travail ConfirmEnableWorkstation=Voulez-vous vraiment activer le poste de travail %s? @@ -130,10 +130,8 @@ Manufacturing=Fabrication Disassemble=Déassemblage ProducedBy=Produit par QtyTot=Qté totale - QtyCantBeSplit= Quantité non fractionnable NoRemainQtyToDispatch=Aucune quantité restant à fractionner - THMOperatorEstimatedHelp=Coût estimé de l'opérateur par heure. Sera utilisé pour estimer le coût d'une nomenclature utilisant ce poste de travail. THMMachineEstimatedHelp=Coût estimé de la machine par heure. Sera utilisé pour estimer le coût d'une nomenclature utilisant ce poste de travail. - +BadValueForquantityToConsume=La quantité à consommer d'un composant ne peut être 0 ou négative diff --git a/htdocs/mrp/class/mo.class.php b/htdocs/mrp/class/mo.class.php index ebc66fdcaad7a..9e47e229f03a7 100644 --- a/htdocs/mrp/class/mo.class.php +++ b/htdocs/mrp/class/mo.class.php @@ -692,6 +692,8 @@ public function update(User $user, $notrigger = false) */ public function createProduction(User $user, $notrigger = true) { + global $langs; + $error = 0; $role = ""; From 18364a5ff0a061027ce5736230c88f1f2dd23ca4 Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Thu, 26 Sep 2024 08:30:42 +0200 Subject: [PATCH 3/4] fix: error return in mo creation when qty to consume is 0 --- htdocs/mrp/class/mo.class.php | 3 --- 1 file changed, 3 deletions(-) diff --git a/htdocs/mrp/class/mo.class.php b/htdocs/mrp/class/mo.class.php index 9e47e229f03a7..a002d16da876e 100644 --- a/htdocs/mrp/class/mo.class.php +++ b/htdocs/mrp/class/mo.class.php @@ -692,8 +692,6 @@ public function update(User $user, $notrigger = false) */ public function createProduction(User $user, $notrigger = true) { - global $langs; - $error = 0; $role = ""; @@ -745,7 +743,6 @@ public function createProduction(User $user, $notrigger = true) $this->error = $moline->error; $this->errors = $moline->errors; dol_print_error($this->db, $moline->error, $moline->errors); - exit; } if ($this->fk_bom > 0) { // If a BOM is defined, we know what to consume. From cc25055b046d46365b8429d9bb20d4947b82d80d Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Thu, 26 Sep 2024 08:31:33 +0200 Subject: [PATCH 4/4] fix: error return in mo creation when qty to consume is 0 --- htdocs/mrp/class/mo.class.php | 1 + htdocs/mrp/mo_card.php | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/mrp/class/mo.class.php b/htdocs/mrp/class/mo.class.php index a002d16da876e..c7bbc5ae1fc78 100644 --- a/htdocs/mrp/class/mo.class.php +++ b/htdocs/mrp/class/mo.class.php @@ -793,6 +793,7 @@ public function createProduction(User $user, $notrigger = true) } } } + if (!$error) { $this->db->commit(); return 1; diff --git a/htdocs/mrp/mo_card.php b/htdocs/mrp/mo_card.php index d6300fdb2b587..e232f34aa1c5e 100644 --- a/htdocs/mrp/mo_card.php +++ b/htdocs/mrp/mo_card.php @@ -146,7 +146,6 @@ // Create MO with Childs if ($action == 'add' && empty($id) && !empty($TBomLineId)) { $noback = 1; - include DOL_DOCUMENT_ROOT.'/core/actions_addupdatedelete.inc.php'; $mo_parent = $object;