Dolibarr / dolibarr

Dolibarr ERP CRM is a modern software package to manage your company or foundation's activity (contacts, suppliers, invoices, orders, stocks, agenda, accounting, ...). it's an open source Web application (written in PHP) designed for businesses of any sizes, foundations and freelancers.
https://www.dolibarr.org
GNU General Public License v3.0
5.46k stars 2.79k forks source link

Hidden extrafields of type boolean are set to 0 on update #29353

Open glu000 opened 7 months ago

glu000 commented 7 months ago

Bug

Hidden extrafields of type boolean are set to 0 on update. Can only happen with extrafields in positions of commercial elements (facture, propal, commande, etc)

Dolibarr Version

18, 19, develop

Environment PHP

na

Environment Database

na

Steps to reproduce the behavior and expected behavior

  1. Create an extrafield of type boolean for an invoice or proposal or order on the lines (DB: ....det_extrafields) and set visibility to 1
  2. Create a new line (position) of an element where you have created the extrafield and enable the checkbox
  3. Set the visibility of the extrafield created in step 1 to 0
  4. Edit the line which has been created in step 2. Doesn't matter what is changed, just important to push the "save" button
  5. Set the visibility of the extrafield created in step 1 to 1
  6. View the line created in step 2 - Checkbox is not set (value 0)

Attached files

No response

JonBendtsen commented 7 months ago

I see the same on Tuxgasy development Dolibarr container image.

Dolibarr Version: 20.0.0-alpha PHP version: 8.2.7 DB version: 10.11.7-MariaDB-1:10.11.7+maria~ubu2204 OS version: Linux dolipod_develop 6.7.9-200.fc39.x86_64 #1 SMP PREEMPT_DYNAMIC Wed Mar 6 19:35:04 UTC 2024 x86_64

json from API on the extrafield for propal lines

{
  "propaldet": {
    "glu000": {
      "id": "5",
      "type": "boolean",
      "label": "glu000",
      "size": "",
      "elementtype": "propaldet",
      "default": null,
      "computed": null,
      "unique": "0",
      "required": "0",
      "param": {
        "options": {
          "": null
        }
      },
      "pos": "100",
      "alwayseditable": "1",
      "perms": null,
      "list": "1",
      "printable": "1",
      "totalizable": "0",
      "langs": null,
      "help": null,
      "css": null,
      "cssview": null,
      "csslist": null,
      "fk_user_author": "1",
      "fk_user_modif": "1",
      "datec": "2024-04-15 23:17:58",
      "tms": "2024-04-15 23:17:58"
    }
  }
}

the proposal Json before ticking that Complementary Attribute

{
  "module": null,
  "id": "1",
  "newid": null,
  "entity": "1",
  "import_key": null,
  "array_options": [],
  "array_languages": null,
  "contacts_ids": [],
  "linked_objects": null,
  "linkedObjectsIds": [],
  "oldref": null,
  "actionmsg": null,
  "actionmsg2": null,
  "canvas": null,
  "fk_project": null,
  "contact_id": null,
  "user": null,
  "origin_type": null,
  "origin_id": null,
  "origin_object": null,
  "origin": null,
  "ref": "(PROV1)",
  "ref_ext": "",
  "status": 0,
  "country_id": null,
  "country_code": null,
  "state_id": null,
  "fk_departement": null,
  "region_id": null,
  "barcode_type": null,
  "barcode_type_coder": null,
  "mode_reglement_id": null,
  "cond_reglement_id": null,
  "demand_reason_id": "0",
  "transport_mode_id": null,
  "shipping_method_id": null,
  "shipping_method": null,
  "fk_multicurrency": "0",
  "multicurrency_code": "DKK",
  "multicurrency_tx": "1.00000000",
  "multicurrency_total_ht": "0.00000000",
  "multicurrency_total_tva": "0.00000000",
  "multicurrency_total_ttc": "0.00000000",
  "multicurrency_total_localtax1": null,
  "multicurrency_total_localtax2": null,
  "last_main_doc": "propale/(PROV1)/(PROV1).pdf",
  "fk_bank": null,
  "fk_account": null,
  "note_public": "",
  "total_ht": "0.00000000",
  "total_tva": "0.00000000",
  "total_localtax1": "0.00000000",
  "total_localtax2": "0.00000000",
  "total_ttc": "0.00000000",
  "lines": [
    {
      "module": null,
      "id": "1",
      "newid": null,
      "entity": null,
      "import_key": null,
      "array_options": {
        "options_glu000": null
      },
      "array_languages": null,
      "contacts_ids": null,
      "linked_objects": null,
      "linkedObjectsIds": null,
      "oldref": null,
      "actionmsg": null,
      "actionmsg2": null,
      "canvas": null,
      "origin_type": null,
      "origin_id": null,
      "origin_object": null,
      "origin": null,
      "ref": "glu000_product",
      "ref_ext": null,
      "status": null,
      "state_id": null,
      "fk_departement": null,
      "region_id": null,
      "barcode_type": null,
      "barcode_type_coder": null,
      "demand_reason_id": null,
      "transport_mode_id": null,
      "shipping_method": null,
      "multicurrency_tx": null,
      "multicurrency_total_ht": "0.00000000",
      "multicurrency_total_tva": "0.00000000",
      "multicurrency_total_ttc": "0.00000000",
      "multicurrency_total_localtax1": null,
      "multicurrency_total_localtax2": null,
      "last_main_doc": null,
      "fk_bank": null,
      "fk_account": null,
      "total_ht": "0.00000000",
      "total_tva": "0.00000000",
      "total_localtax1": "0.00000000",
      "total_localtax2": "0.00000000",
      "total_ttc": "0.00000000",
      "lines": null,
      "actiontypecode": null,
      "date_creation": null,
      "date_validation": null,
      "date_modification": null,
      "tms": null,
      "date_cloture": null,
      "user_author": null,
      "user_creation": null,
      "user_creation_id": null,
      "user_valid": null,
      "user_validation": null,
      "user_validation_id": null,
      "user_closing_id": null,
      "user_modification": null,
      "user_modification_id": null,
      "fk_user_creat": null,
      "fk_user_modif": null,
      "specimen": 0,
      "labelStatus": [],
      "labelStatusShort": [],
      "tpl": null,
      "showphoto_on_popup": null,
      "nb": [],
      "nbphoto": null,
      "output": null,
      "extraparams": [],
      "product": null,
      "cond_reglement_supplier_id": null,
      "deposit_percent": null,
      "retained_warranty_fk_cond_reglement": null,
      "warehouse_id": null,
      "rowid": "1",
      "fk_unit": null,
      "date_debut_prevue": null,
      "date_debut_reel": null,
      "date_fin_prevue": null,
      "date_fin_reel": null,
      "weight": null,
      "weight_units": null,
      "width": null,
      "width_units": null,
      "height": null,
      "height_units": null,
      "length": null,
      "length_units": null,
      "surface": null,
      "surface_units": null,
      "volume": null,
      "volume_units": null,
      "multilangs": null,
      "product_type": "0",
      "fk_product": "1",
      "desc": "",
      "description": "",
      "product_ref": "glu000_product",
      "product_label": "glu000_product",
      "product_barcode": null,
      "product_desc": "",
      "fk_product_type": "0",
      "qty": "1",
      "duree": null,
      "remise_percent": "0",
      "info_bits": "0",
      "special_code": "0",
      "subprice": "0.00000000",
      "tva_tx": "0.0000",
      "multicurrency_subprice": "0.00000000",
      "fk_propal": "1",
      "fk_parent_line": null,
      "vat_src_code": "",
      "fk_remise_except": null,
      "rang": "1",
      "fk_fournprice": null,
      "pa_ht": "0.00000000",
      "marge_tx": "",
      "marque_tx": "",
      "remise": null,
      "price": "0",
      "libelle": "glu000_product",
      "label": null,
      "product_tobatch": "0",
      "localtax1_tx": "0.0000",
      "localtax2_tx": "0.0000",
      "localtax1_type": "0",
      "localtax2_type": "0",
      "date_start": "",
      "date_end": ""
    }
  ],
  "actiontypecode": null,
  "date_creation": 1713215730,
  "date_validation": "",
  "date_modification": 1713215730,
  "tms": null,
  "date_cloture": null,
  "user_author": null,
  "user_creation": null,
  "user_creation_id": null,
  "user_valid": null,
  "user_validation": null,
  "user_validation_id": null,
  "user_closing_id": null,
  "user_modification": null,
  "user_modification_id": null,
  "fk_user_creat": null,
  "fk_user_modif": null,
  "specimen": 0,
  "labelStatus": [],
  "labelStatusShort": [],
  "tpl": null,
  "showphoto_on_popup": null,
  "nb": [],
  "nbphoto": null,
  "output": null,
  "extraparams": [],
  "product": null,
  "cond_reglement_supplier_id": null,
  "deposit_percent": null,
  "retained_warranty_fk_cond_reglement": null,
  "warehouse_id": null,
  "code": "",
  "socid": "1",
  "contactid": null,
  "ref_client": "glu000_customer_ref",
  "ref_customer": "glu000_customer_ref",
  "statut": 0,
  "datec": 1713215730,
  "datev": "",
  "date_signature": "",
  "user_signature": null,
  "date": 1713132000,
  "datep": 1713132000,
  "delivery_date": "",
  "fin_validite": 1714471200,
  "user_author_id": "1",
  "price": null,
  "tva": null,
  "total": "0.00000000",
  "cond_reglement_code": null,
  "cond_reglement_doc": null,
  "mode_reglement_code": null,
  "fk_address": null,
  "address_type": null,
  "availability_id": "0",
  "fk_availability": null,
  "availability_code": null,
  "availability": null,
  "duree_validite": 15,
  "demand_reason_code": null,
  "demand_reason": null,
  "line": null,
  "fk_incoterms": "0",
  "label_incoterms": null,
  "location_incoterms": ""
}

ticking that extrafield

{
  "module": null,
  "id": "1",
  "newid": null,
  "entity": "1",
  "import_key": null,
  "array_options": [],
  "array_languages": null,
  "contacts_ids": [],
  "linked_objects": null,
  "linkedObjectsIds": [],
  "oldref": null,
  "actionmsg": null,
  "actionmsg2": null,
  "canvas": null,
  "fk_project": null,
  "contact_id": null,
  "user": null,
  "origin_type": null,
  "origin_id": null,
  "origin_object": null,
  "origin": null,
  "ref": "(PROV1)",
  "ref_ext": "",
  "status": 0,
  "country_id": null,
  "country_code": null,
  "state_id": null,
  "fk_departement": null,
  "region_id": null,
  "barcode_type": null,
  "barcode_type_coder": null,
  "mode_reglement_id": null,
  "cond_reglement_id": null,
  "demand_reason_id": "0",
  "transport_mode_id": null,
  "shipping_method_id": null,
  "shipping_method": null,
  "fk_multicurrency": "0",
  "multicurrency_code": "DKK",
  "multicurrency_tx": "1.00000000",
  "multicurrency_total_ht": "0.00000000",
  "multicurrency_total_tva": "0.00000000",
  "multicurrency_total_ttc": "0.00000000",
  "multicurrency_total_localtax1": null,
  "multicurrency_total_localtax2": null,
  "last_main_doc": "propale/(PROV1)/(PROV1).pdf",
  "fk_bank": null,
  "fk_account": null,
  "note_public": "",
  "total_ht": "0.00000000",
  "total_tva": "0.00000000",
  "total_localtax1": "0.00000000",
  "total_localtax2": "0.00000000",
  "total_ttc": "0.00000000",
  "lines": [
    {
      "module": null,
      "id": "1",
      "newid": null,
      "entity": null,
      "import_key": null,
      "array_options": {
        "options_glu000": "1"
      },
      "array_languages": null,
      "contacts_ids": null,
      "linked_objects": null,
      "linkedObjectsIds": null,
      "oldref": null,
      "actionmsg": null,
      "actionmsg2": null,
      "canvas": null,
      "origin_type": null,
      "origin_id": null,
      "origin_object": null,
      "origin": null,
      "ref": "glu000_product",
      "ref_ext": null,
      "status": null,
      "state_id": null,
      "fk_departement": null,
      "region_id": null,
      "barcode_type": null,
      "barcode_type_coder": null,
      "demand_reason_id": null,
      "transport_mode_id": null,
      "shipping_method": null,
      "multicurrency_tx": null,
      "multicurrency_total_ht": "0.00000000",
      "multicurrency_total_tva": "0.00000000",
      "multicurrency_total_ttc": "0.00000000",
      "multicurrency_total_localtax1": null,
      "multicurrency_total_localtax2": null,
      "last_main_doc": null,
      "fk_bank": null,
      "fk_account": null,
      "total_ht": "0.00000000",
      "total_tva": "0.00000000",
      "total_localtax1": "0.00000000",
      "total_localtax2": "0.00000000",
      "total_ttc": "0.00000000",
      "lines": null,
      "actiontypecode": null,
      "date_creation": null,
      "date_validation": null,
      "date_modification": null,
      "tms": null,
      "date_cloture": null,
      "user_author": null,
      "user_creation": null,
      "user_creation_id": null,
      "user_valid": null,
      "user_validation": null,
      "user_validation_id": null,
      "user_closing_id": null,
      "user_modification": null,
      "user_modification_id": null,
      "fk_user_creat": null,
      "fk_user_modif": null,
      "specimen": 0,
      "labelStatus": [],
      "labelStatusShort": [],
      "tpl": null,
      "showphoto_on_popup": null,
      "nb": [],
      "nbphoto": null,
      "output": null,
      "extraparams": [],
      "product": null,
      "cond_reglement_supplier_id": null,
      "deposit_percent": null,
      "retained_warranty_fk_cond_reglement": null,
      "warehouse_id": null,
      "rowid": "1",
      "fk_unit": null,
      "date_debut_prevue": null,
      "date_debut_reel": null,
      "date_fin_prevue": null,
      "date_fin_reel": null,
      "weight": null,
      "weight_units": null,
      "width": null,
      "width_units": null,
      "height": null,
      "height_units": null,
      "length": null,
      "length_units": null,
      "surface": null,
      "surface_units": null,
      "volume": null,
      "volume_units": null,
      "multilangs": null,
      "product_type": "0",
      "fk_product": "1",
      "desc": "",
      "description": "",
      "product_ref": "glu000_product",
      "product_label": "glu000_product",
      "product_barcode": null,
      "product_desc": "",
      "fk_product_type": "0",
      "qty": "1",
      "duree": null,
      "remise_percent": "0",
      "info_bits": "0",
      "special_code": "0",
      "subprice": "0.00000000",
      "tva_tx": "0.0000",
      "multicurrency_subprice": "0.00000000",
      "fk_propal": "1",
      "fk_parent_line": null,
      "vat_src_code": "",
      "fk_remise_except": null,
      "rang": "1",
      "fk_fournprice": null,
      "pa_ht": "0.00000000",
      "marge_tx": "",
      "marque_tx": "",
      "remise": null,
      "price": "0",
      "libelle": "glu000_product",
      "label": null,
      "product_tobatch": "0",
      "localtax1_tx": "0.0000",
      "localtax2_tx": "0.0000",
      "localtax1_type": "0",
      "localtax2_type": "0",
      "date_start": "",
      "date_end": ""
    }
  ],
  "actiontypecode": null,
  "date_creation": 1713215730,
  "date_validation": "",
  "date_modification": 1713215730,
  "tms": null,
  "date_cloture": null,
  "user_author": null,
  "user_creation": null,
  "user_creation_id": null,
  "user_valid": null,
  "user_validation": null,
  "user_validation_id": null,
  "user_closing_id": null,
  "user_modification": null,
  "user_modification_id": null,
  "fk_user_creat": null,
  "fk_user_modif": null,
  "specimen": 0,
  "labelStatus": [],
  "labelStatusShort": [],
  "tpl": null,
  "showphoto_on_popup": null,
  "nb": [],
  "nbphoto": null,
  "output": null,
  "extraparams": [],
  "product": null,
  "cond_reglement_supplier_id": null,
  "deposit_percent": null,
  "retained_warranty_fk_cond_reglement": null,
  "warehouse_id": null,
  "code": "",
  "socid": "1",
  "contactid": null,
  "ref_client": "glu000_customer_ref",
  "ref_customer": "glu000_customer_ref",
  "statut": 0,
  "datec": 1713215730,
  "datev": "",
  "date_signature": "",
  "user_signature": null,
  "date": 1713132000,
  "datep": 1713132000,
  "delivery_date": "",
  "fin_validite": 1714471200,
  "user_author_id": "1",
  "price": null,
  "tva": null,
  "total": "0.00000000",
  "cond_reglement_code": null,
  "cond_reglement_doc": null,
  "mode_reglement_code": null,
  "fk_address": null,
  "address_type": null,
  "availability_id": "0",
  "fk_availability": null,
  "availability_code": null,
  "availability": null,
  "duree_validite": 15,
  "demand_reason_code": null,
  "demand_reason": null,
  "line": null,
  "fk_incoterms": "0",
  "label_incoterms": null,
  "location_incoterms": ""
}

only getting the propal lines with it ticked

[
  {
    "module": null,
    "id": "1",
    "newid": null,
    "entity": null,
    "import_key": null,
    "array_options": {
      "options_glu000": "1"
    },
    "array_languages": null,
    "contacts_ids": null,
    "linked_objects": null,
    "linkedObjectsIds": null,
    "oldref": null,
    "actionmsg": null,
    "actionmsg2": null,
    "canvas": null,
    "fk_project": null,
    "contact_id": null,
    "user": null,
    "origin_type": null,
    "origin_id": null,
    "origin_object": null,
    "origin": null,
    "ref": "glu000_product",
    "ref_ext": null,
    "status": null,
    "country_id": null,
    "country_code": null,
    "state_id": null,
    "fk_departement": null,
    "region_id": null,
    "barcode_type": null,
    "barcode_type_coder": null,
    "mode_reglement_id": null,
    "cond_reglement_id": null,
    "demand_reason_id": null,
    "transport_mode_id": null,
    "shipping_method_id": null,
    "shipping_method": null,
    "fk_multicurrency": null,
    "multicurrency_code": "DKK",
    "multicurrency_tx": null,
    "multicurrency_total_ht": "0.00000000",
    "multicurrency_total_tva": "0.00000000",
    "multicurrency_total_ttc": "0.00000000",
    "multicurrency_total_localtax1": null,
    "multicurrency_total_localtax2": null,
    "last_main_doc": null,
    "fk_bank": null,
    "fk_account": null,
    "note_public": null,
    "total_ht": "0.00000000",
    "total_tva": "0.00000000",
    "total_localtax1": "0.00000000",
    "total_localtax2": "0.00000000",
    "total_ttc": "0.00000000",
    "lines": null,
    "actiontypecode": null,
    "date_creation": null,
    "date_validation": null,
    "date_modification": null,
    "tms": null,
    "date_cloture": null,
    "user_author": null,
    "user_creation": null,
    "user_creation_id": null,
    "user_valid": null,
    "user_validation": null,
    "user_validation_id": null,
    "user_closing_id": null,
    "user_modification": null,
    "user_modification_id": null,
    "fk_user_creat": null,
    "fk_user_modif": null,
    "specimen": 0,
    "labelStatus": [],
    "labelStatusShort": [],
    "tpl": null,
    "showphoto_on_popup": null,
    "nb": [],
    "nbphoto": null,
    "output": null,
    "extraparams": [],
    "product": null,
    "cond_reglement_supplier_id": null,
    "deposit_percent": null,
    "retained_warranty_fk_cond_reglement": null,
    "warehouse_id": null,
    "rowid": "1",
    "fk_unit": null,
    "date_debut_prevue": null,
    "date_debut_reel": null,
    "date_fin_prevue": null,
    "date_fin_reel": null,
    "weight": null,
    "weight_units": null,
    "width": null,
    "width_units": null,
    "height": null,
    "height_units": null,
    "length": null,
    "length_units": null,
    "surface": null,
    "surface_units": null,
    "volume": null,
    "volume_units": null,
    "multilangs": null,
    "product_type": "0",
    "fk_product": "1",
    "desc": "",
    "description": "",
    "product_ref": "glu000_product",
    "product_label": "glu000_product",
    "product_barcode": null,
    "product_desc": "",
    "fk_product_type": "0",
    "qty": "1",
    "duree": null,
    "remise_percent": "0",
    "info_bits": "0",
    "special_code": "0",
    "subprice": "0.00000000",
    "tva_tx": "0.0000",
    "multicurrency_subprice": "0.00000000",
    "fk_propal": "1",
    "fk_parent_line": null,
    "vat_src_code": "",
    "fk_remise_except": null,
    "rang": "1",
    "fk_fournprice": null,
    "pa_ht": "0.00000000",
    "marge_tx": "",
    "marque_tx": "",
    "remise": null,
    "price": "0",
    "libelle": "glu000_product",
    "label": null,
    "product_tobatch": "0",
    "localtax1_tx": "0.0000",
    "localtax2_tx": "0.0000",
    "localtax1_type": "0",
    "localtax2_type": "0",
    "date_start": "",
    "date_end": ""
  }
]

extrafield json after setting visibility to 0

{
  "propaldet": {
    "glu000": {
      "id": "6",
      "type": "boolean",
      "label": "glu000",
      "size": "",
      "elementtype": "propaldet",
      "default": null,
      "computed": null,
      "unique": "0",
      "required": "0",
      "param": {
        "options": {
          "": null
        }
      },
      "pos": "100",
      "alwayseditable": "1",
      "perms": null,
      "list": "0",
      "printable": "1",
      "totalizable": "0",
      "langs": null,
      "help": null,
      "css": null,
      "cssview": null,
      "csslist": null,
      "fk_user_author": "1",
      "fk_user_modif": "1",
      "datec": "2024-04-15 23:29:05",
      "tms": "2024-04-15 23:29:05"
    }
  }
}

json of the propal lines are still with a value

[
  {
    "module": null,
    "id": "1",
    "newid": null,
    "entity": null,
    "import_key": null,
    "array_options": {
      "options_glu000": "1"
    },
    "array_languages": null,
    "contacts_ids": null,
    "linked_objects": null,
    "linkedObjectsIds": null,
    "oldref": null,
    "actionmsg": null,
    "actionmsg2": null,
    "canvas": null,
    "fk_project": null,
    "contact_id": null,
    "user": null,
    "origin_type": null,
    "origin_id": null,
    "origin_object": null,
    "origin": null,
    "ref": "glu000_product",
    "ref_ext": null,
    "status": null,
    "country_id": null,
    "country_code": null,
    "state_id": null,
    "fk_departement": null,
    "region_id": null,
    "barcode_type": null,
    "barcode_type_coder": null,
    "mode_reglement_id": null,
    "cond_reglement_id": null,
    "demand_reason_id": null,
    "transport_mode_id": null,
    "shipping_method_id": null,
    "shipping_method": null,
    "fk_multicurrency": null,
    "multicurrency_code": "DKK",
    "multicurrency_tx": null,
    "multicurrency_total_ht": "0.00000000",
    "multicurrency_total_tva": "0.00000000",
    "multicurrency_total_ttc": "0.00000000",
    "multicurrency_total_localtax1": null,
    "multicurrency_total_localtax2": null,
    "last_main_doc": null,
    "fk_bank": null,
    "fk_account": null,
    "note_public": null,
    "total_ht": "0.00000000",
    "total_tva": "0.00000000",
    "total_localtax1": "0.00000000",
    "total_localtax2": "0.00000000",
    "total_ttc": "0.00000000",
    "lines": null,
    "actiontypecode": null,
    "date_creation": null,
    "date_validation": null,
    "date_modification": null,
    "tms": null,
    "date_cloture": null,
    "user_author": null,
    "user_creation": null,
    "user_creation_id": null,
    "user_valid": null,
    "user_validation": null,
    "user_validation_id": null,
    "user_closing_id": null,
    "user_modification": null,
    "user_modification_id": null,
    "fk_user_creat": null,
    "fk_user_modif": null,
    "specimen": 0,
    "labelStatus": [],
    "labelStatusShort": [],
    "tpl": null,
    "showphoto_on_popup": null,
    "nb": [],
    "nbphoto": null,
    "output": null,
    "extraparams": [],
    "product": null,
    "cond_reglement_supplier_id": null,
    "deposit_percent": null,
    "retained_warranty_fk_cond_reglement": null,
    "warehouse_id": null,
    "rowid": "1",
    "fk_unit": null,
    "date_debut_prevue": null,
    "date_debut_reel": null,
    "date_fin_prevue": null,
    "date_fin_reel": null,
    "weight": null,
    "weight_units": null,
    "width": null,
    "width_units": null,
    "height": null,
    "height_units": null,
    "length": null,
    "length_units": null,
    "surface": null,
    "surface_units": null,
    "volume": null,
    "volume_units": null,
    "multilangs": null,
    "product_type": "0",
    "fk_product": "1",
    "desc": "",
    "description": "",
    "product_ref": "glu000_product",
    "product_label": "glu000_product",
    "product_barcode": null,
    "product_desc": "",
    "fk_product_type": "0",
    "qty": "1",
    "duree": null,
    "remise_percent": "0",
    "info_bits": "0",
    "special_code": "0",
    "subprice": "0.00000000",
    "tva_tx": "0.0000",
    "multicurrency_subprice": "0.00000000",
    "fk_propal": "1",
    "fk_parent_line": null,
    "vat_src_code": "",
    "fk_remise_except": null,
    "rang": "1",
    "fk_fournprice": null,
    "pa_ht": "0.00000000",
    "marge_tx": "",
    "marque_tx": "",
    "remise": null,
    "price": "0",
    "libelle": "glu000_product",
    "label": null,
    "product_tobatch": "0",
    "localtax1_tx": "0.0000",
    "localtax2_tx": "0.0000",
    "localtax1_type": "0",
    "localtax2_type": "0",
    "date_start": "",
    "date_end": ""
  }
]

json of propal line after editing and saving.

[
  {
    "module": null,
    "id": "1",
    "newid": null,
    "entity": null,
    "import_key": null,
    "array_options": {
      "options_glu000": null
    },
    "array_languages": null,
    "contacts_ids": null,
    "linked_objects": null,
    "linkedObjectsIds": null,
    "oldref": null,
    "actionmsg": null,
    "actionmsg2": null,
    "canvas": null,
    "fk_project": null,
    "contact_id": null,
    "user": null,
    "origin_type": null,
    "origin_id": null,
    "origin_object": null,
    "origin": null,
    "ref": "glu000_product",
    "ref_ext": null,
    "status": null,
    "country_id": null,
    "country_code": null,
    "state_id": null,
    "fk_departement": null,
    "region_id": null,
    "barcode_type": null,
    "barcode_type_coder": null,
    "mode_reglement_id": null,
    "cond_reglement_id": null,
    "demand_reason_id": null,
    "transport_mode_id": null,
    "shipping_method_id": null,
    "shipping_method": null,
    "fk_multicurrency": null,
    "multicurrency_code": "DKK",
    "multicurrency_tx": null,
    "multicurrency_total_ht": "0.00000000",
    "multicurrency_total_tva": "0.00000000",
    "multicurrency_total_ttc": "0.00000000",
    "multicurrency_total_localtax1": null,
    "multicurrency_total_localtax2": null,
    "last_main_doc": null,
    "fk_bank": null,
    "fk_account": null,
    "note_public": null,
    "total_ht": "0.00000000",
    "total_tva": "0.00000000",
    "total_localtax1": "0.00000000",
    "total_localtax2": "0.00000000",
    "total_ttc": "0.00000000",
    "lines": null,
    "actiontypecode": null,
    "date_creation": null,
    "date_validation": null,
    "date_modification": null,
    "tms": null,
    "date_cloture": null,
    "user_author": null,
    "user_creation": null,
    "user_creation_id": null,
    "user_valid": null,
    "user_validation": null,
    "user_validation_id": null,
    "user_closing_id": null,
    "user_modification": null,
    "user_modification_id": null,
    "fk_user_creat": null,
    "fk_user_modif": null,
    "specimen": 0,
    "labelStatus": [],
    "labelStatusShort": [],
    "tpl": null,
    "showphoto_on_popup": null,
    "nb": [],
    "nbphoto": null,
    "output": null,
    "extraparams": [],
    "product": null,
    "cond_reglement_supplier_id": null,
    "deposit_percent": null,
    "retained_warranty_fk_cond_reglement": null,
    "warehouse_id": null,
    "rowid": "1",
    "fk_unit": null,
    "date_debut_prevue": null,
    "date_debut_reel": null,
    "date_fin_prevue": null,
    "date_fin_reel": null,
    "weight": null,
    "weight_units": null,
    "width": null,
    "width_units": null,
    "height": null,
    "height_units": null,
    "length": null,
    "length_units": null,
    "surface": null,
    "surface_units": null,
    "volume": null,
    "volume_units": null,
    "multilangs": null,
    "product_type": "0",
    "fk_product": "1",
    "desc": "",
    "description": "",
    "product_ref": "glu000_product",
    "product_label": "glu000_product",
    "product_barcode": null,
    "product_desc": "",
    "fk_product_type": "0",
    "qty": "1",
    "duree": null,
    "remise_percent": "0",
    "info_bits": "0",
    "special_code": "0",
    "subprice": "0.00000000",
    "tva_tx": "0.0000",
    "multicurrency_subprice": "0.00000000",
    "fk_propal": "1",
    "fk_parent_line": null,
    "vat_src_code": "",
    "fk_remise_except": null,
    "rang": "1",
    "fk_fournprice": null,
    "pa_ht": "0.00000000",
    "marge_tx": "",
    "marque_tx": "",
    "remise": null,
    "price": "0",
    "libelle": "glu000_product",
    "label": null,
    "product_tobatch": "0",
    "localtax1_tx": "0.0000",
    "localtax2_tx": "0.0000",
    "localtax1_type": "0",
    "localtax2_type": "0",
    "date_start": "",
    "date_end": ""
  }
]

The value is now back to null even though we never actually changed the value, only the definition and the visibility.

JonBendtsen commented 7 months ago

Looking in the database llx_propaldet_extrafields

the rowid number changes every time the propal line is edited, and during this process the glu000 value gets reset to NULL - my guess is that it inserts a new line in the database.

JonBendtsen commented 7 months ago

@glu000 I think the code here is why that value disappears when you hide and unhide it.

https://github.com/Dolibarr/dolibarr/blob/develop/htdocs/core/class/extrafields.class.php#L819-L888

JonBendtsen commented 7 months ago

@eldy is there some technical reason for why the extrafield is first deleted from the database and then created again?

Why not just use UPDATE?

eldy commented 2 months ago

@eldy is there some technical reason for why the extrafield is first deleted from the database and then created again?

Why not just use UPDATE?

Historical reason. Sometimes the line into the extrafields does not exists at all, so we can't update, we must insert. The delete/insert was an easy way to do this without getting the error when doing insert if line already exists. And the update method did not exists. A bad practice that must be removed. There is now no reason to continue to do delete/insert because the update method should now exists i think (not sure).