dolibarr icon indicating copy to clipboard operation
dolibarr copied to clipboard

Les ExtraFields « cases à cocher du tableau » sur l’ordre de fabrication suppriment les données précédentes sur ces champs supplémentaires

Open levelit opened this issue 1 year ago • 7 comments

Bug

Bonjour a tous!

Je suis actuellement en train de personnaliser le module Ordre de fabrication et j’ai ajouté quelques champs supplémentaires.

Nous sommes confrontés à un problème étrange uniquement dans le module MO. Nous avons créé 4 champs supplémentaires de « Cases à cocher du tableau ». -1 récupère les informations de la table des ressources -2 récupérer les informations des utilisateurs -1 récupère les informations d’un dictionnaire personnalisé (créé par un petit module personnalisé)

Le problème est que vous pouvez compléter et remplir tous les champs supplémentaires lorsque vous « modifiez » les informations, mais lorsque vous utilisez l’édition en ligne, 1 EF conserve les données mais les 3 autres perdent les informations.

La version de Dolibarr est la 18.0.3

Ci-dessous j’ajoute 3 images dans l’ordre d’exécution: Capture1_all Check boxes EF - complete Capture2_all Check boxes EF - only 1 modification Capture3_all Check boxes EF - after modification

Toute aide sera volontiers appréciée. :slight_smile:

Désolé pour mon français, c’est un texte traduit par Google. J’espère que c’est compréhensible.

C'était mon message sur le forum: https://www.dolibarr.fr/forum/t/les-extrafields-cases-a-cocher-du-tableau-sur-lordre-de-fabrication-suppriment-les-donnees-precedentes-sur-ces-champs-supplementaires/45465

Environment Version

18.0.3

Environment OS

No response

Environment Web server

2.4.51

Environment PHP

7.4.26

Environment Database

Maria DB 10.6.5

Environment URL(s)

No response

Expected and actual behavior

No response

Steps to reproduce the behavior

No response

Attached files

No response

levelit avatar Feb 01 '24 17:02 levelit

Well...we digged a little more and we believe we found the solution.

The problem was located at: File: htdocs/core/class/extrafields.class
Method: SetOptionalsFromPost Line: 2167

We replaced this code:

$value_arr = GETPOST("options_".$key, 'array'); // check if an array
if (!empty($value_arr)) {
	$value_key = implode(',', $value_arr);
} else {
	$value_key = '';
}

With this:

$value_arr = GETPOST("options_".$key); // check if an array
$attr = GETPOST("attribute");
if (!empty($value_arr) && $key == $attr){
	$value_key = implode(',', $value_arr);
}elseif (empty($value_arr) && $key != $attr) {
	$value_key = $object->array_options["options_".$key];
}
elseif ((empty($value_arr) && $key == $attr)){
	$value_key = $value_arr;
}

I hope it can help :(

levelit avatar Feb 01 '24 22:02 levelit

I don't know french, but what if you submitted a merge request? You don't even need to clone the repo, just edit this file directly here in the online editor, and create either a new branch, or directly a pull request.

https://github.com/Dolibarr/dolibarr/edit/develop/htdocs/core/class/extrafields.class.php

JonBendtsen avatar Feb 01 '24 22:02 JonBendtsen

Hi Jon! Sorry I posted in French forum initially. This is the problem brief: ExtraFields “Checkboxes from table” on Manufacturing Order remove previous data on these extrafields

This is the link https://www.dolibarr.org/forum/t/extrafields-checkboxes-from-table-on-manufacturing-order-remove-previous-data-on-these-extrafields/24904

In the French forum they suggested me to post as a bug but we kept digging and found a possible solution with the above code replacement.

I can happily collaborate with this fix.

levelit avatar Feb 02 '24 12:02 levelit

We are also affected by this issue in 18.0.4, it concerns the field types:

  • Boolean (one checkbox)
  • Checkboxes

other fields like check boxes and url's are not affected by this issue. I have applied the above patch and will do some testing to see if it works.

erikvanberkum avatar Feb 07 '24 22:02 erikvanberkum

This issue affects beside MO also the BOM module.

erikvanberkum avatar Feb 08 '24 03:02 erikvanberkum

Hi Erik!

We tested it out a little bit more beacuse we found it also affected creation and modification, not only inline edition.

We improved the code to be replaced as follows:

$value_arr = GETPOST("options_".$key); 
$attr = GETPOST("attribute");
$value_key = '';

if (!empty($value_arr) && $key == $attr){
         $value_key = implode(',', $value_arr);
}elseif (empty($value_arr) && $key != $attr) {
         $value_key = $object->array_options["options_".$key];
}
elseif ((empty($value_arr) && $key == $attr)){
         $value_key = $value_arr;
}
elseif (!empty($value_arr) && empty($attr)){
        $value_key = implode(',', $value_arr);
}
elseif(empty($value_arr) && empty($attr)){
        $value_key = '';
}

levelit avatar Feb 08 '24 12:02 levelit

Levelit,

Thanks for the update this 2nd patch improved the Checkboxes (product group tags) they are not disappearing anymore.

image

Currently its still not possible to have both Child-BOM and 3D CAD selected, when i select 1 the other goes off.

When i edit the product groep Child-BOM and 3D CAD are set back to the 0 status.

erikvanberkum avatar Feb 09 '24 02:02 erikvanberkum

Good morning, I had the same problem. I corrected it by adding a condition below the previous modification.

} elseif (in_array($key_type, array('boolean'))) {
					$value_arr = GETPOST("options_".$key); 
					$attr = GETPOST("attribute");
					$value_key ="";

					if ((empty($value_arr) && $key == $attr)){
							 $value_key = $value_arr;
					}
					elseif (!empty($value_arr) && $key == $attr){
							$value_key = $value_arr;
					}
					else{
						$value_key = $object->array_options["options_".$key];
					}

fabrice049 avatar Apr 03 '24 07:04 fabrice049