How do you update a supplierorders lines via the REST API

We are trying to understand how to update lines of a Supplier Order (supplierorder) using the REST API.

No error message is returned. The endpoint returns a 200 OK status message, but the supplierorder is not being updated. Is this a bug or we are doing something not correct?

Below is the request payload to update the order line on the endpoint http://dev001.xxxx.xxx/api/index.php/supplierorders/58

{
    "lines": [
    {
      "rang": "1",
      "special_code": "0",
      "pu_ht": 1.50000000,
      "ref": "379",
      "libelle": "Soya",
      "product_ref": "379",
      "product_label": "Soya",
      "qty": 400,
      "subprice": 1.50000000,
      "product_type": "0",
      "fk_product": 22,
      "remise_percent": "0",
      "id": 11,
      "total_ht": 600.00000000,
      "total_tva": 0.00000000,
      "total_localtax1": 0.00000000,
      "total_localtax2": 0.00000000,
      "total_ttc": 600.00000000,
      "specimen": 0
    }
  ]

}

Attached is the line that would would like to update.

The response payload returned by the REST API is below

{
  "id": "58",
  "ref": "(PROV58)",
  "ref_supplier": "",
  "brouillon": 1,
  "statut": "0",
  "billed": "0",
  "socid": "28",
  "fourn_id": "28",
  "date": 1657647178,
  "date_creation": 1657647178,
  "date_valid": "",
  "date_approve": "",
  "date_approve2": "",
  "date_commande": "",
  "date_livraison": "",
  "delivery_date": "",
  "total_ht": "300.00000000",
  "total_tva": "0.00000000",
  "total_localtax1": "0.00000000",
  "total_localtax2": "0.00000000",
  "total_ttc": "300.00000000",
  "source": "0",
  "fk_project": null,
  "cond_reglement_id": "1",
  "cond_reglement_code": "RECEP",
  "cond_reglement_label": "Due upon receipt",
  "cond_reglement_doc": "Due upon receipt",
  "fk_account": null,
  "mode_reglement_id": null,
  "mode_reglement_code": null,
  "user_author_id": "1",
  "user_valid_id": null,
  "user_approve_id": null,
  "user_approve_id2": null,
  "refuse_note": null,
  "extraparams": [],
  "lines": [
    {
      "fk_commande": null,
      "fk_parent_line": null,
      "fk_facture": null,
      "rang": "1",
      "special_code": "0",
      "pu_ht": "1.50000000",
      "date_start": "",
      "date_end": "",
      "ref_supplier": "",
      "remise": null,
      "label": null,
      "ref": "379",
      "libelle": "Soya",
      "product_ref": "379",
      "product_label": "Soya",
      "product_desc": "",
      "product_tobatch": "0",
      "product_barcode": null,
      "qty": "200",
      "price": null,
      "subprice": "1.50000000",
      "product_type": "0",
      "desc": "",
      "fk_product": "22",
      "remise_percent": "0",
      "vat_src_code": "",
      "tva_tx": "0.0000",
      "localtax1_tx": "0.0000",
      "localtax2_tx": "0.0000",
      "localtax1_type": "",
      "localtax2_type": "",
      "info_bits": 0,
      "multicurrency_subprice": "1.50000000",
      "multicurrency_total_ht": "300.00000000",
      "multicurrency_total_tva": "0.00000000",
      "multicurrency_total_ttc": "300.00000000",
      "id": "11",
      "fk_unit": null,
      "date_debut_prevue": null,
      "date_debut_reel": null,
      "date_fin_prevue": null,
      "date_fin_reel": null,
      "entity": null,
      "validateFieldsErrors": [],
      "import_key": null,
      "array_options": [],
      "array_languages": null,
      "linkedObjectsIds": null,
      "canvas": null,
      "origin": null,
      "origin_id": null,
      "ref_ext": null,
      "statut": null,
      "status": null,
      "state_id": null,
      "region_id": null,
      "demand_reason_id": null,
      "transport_mode_id": null,
      "last_main_doc": null,
      "fk_bank": null,
      "fk_account": null,
      "total_ht": "300.00000000",
      "total_tva": "0.00000000",
      "total_localtax1": "0.00000000",
      "total_localtax2": "0.00000000",
      "total_ttc": "300.00000000",
      "lines": null,
      "date_creation": null,
      "date_validation": null,
      "date_modification": null,
      "specimen": 0,
      "description": "",
      "ref_fourn": ""
    }
  ],
  "origin": null,
  "origin_id": null,
  "linked_objects": [],
  "fk_multicurrency": "0",
  "multicurrency_code": "ZAR",
  "multicurrency_tx": "1.00000000",
  "multicurrency_total_ht": "300.00000000",
  "multicurrency_total_tva": "0.00000000",
  "multicurrency_total_ttc": "300.00000000",
  "entity": "1",
  "validateFieldsErrors": [],
  "import_key": null,
  "array_options": {
    "options_binid": null,
    "options_commodityid": null,
    "options_gradeid": null,
    "options_vehicleid2": null,
    "options_vehicleid1": "-",
    "options_firstweight": null,
    "options_secondweight": null,
    "options_driveridnumber": null,
    "options_deductions": null,
    "options_netweight": null,
    "options_tickettype": "1",
    "options_factorvalues": null
  },
  "array_languages": null,
  "linkedObjectsIds": [],
  "canvas": null,
  "contact_id": null,
  "user": null,
  "ref_ext": null,
  "status": "0",
  "country_id": null,
  "country_code": null,
  "state_id": null,
  "region_id": null,
  "demand_reason_id": null,
  "transport_mode_id": null,
  "shipping_method_id": null,
  "model_pdf": "muscadet",
  "last_main_doc": null,
  "fk_bank": null,
  "note_public": "",
  "note_private": "",
  "name": null,
  "lastname": null,
  "firstname": null,
  "civility_id": null,
  "date_validation": null,
  "date_modification": null,
  "specimen": 0,
  "fk_incoterms": "0",
  "label_incoterms": null,
  "location_incoterms": "",
  "remise_percent": "0",
  "methode_commande_id": "0",
  "methode_commande": null
}

The reason for this issue is that we do not have the same end points as sales order api.

  1. postLine
  2. putLine
  3. deleteLine

It will be interesting maybe to know why we do not have this currently in Dolibarr for Supplier Orders.

The code to update an order on Supplier Order it just simple fields. However, the lines field is an array that can contain one or more llx_commande_fournisseurdet entities.

Our solution was to create a custom module with the Supplier Order endpoints to:

  1. Add a new order line
  2. Edit an existing order line
  3. Delete an existing order line

We did copy the code from the sale order api_orders.class.php.