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.45k stars 2.79k forks source link

API_ORDER can not set "contacts_ids" #27755

Open Mohammed-el-Amine opened 9 months ago

Mohammed-el-Amine commented 9 months ago

Bug

When I submit the order creation form, it does not allow me to add the contacts for order tracking, delivery, and billing.

When I manually add it using the interface, it changes correctly and provides me with the 'contacts_ids' array in the response of the GET/orders request.

Environment Version

18.0.1

Environment OS

ubuntu

Environment Web server

ubuntu

Environment PHP

=8.1

Environment Database

SQL

Environment URL(s)

dolibarr/htdocs/api/index.php/orders

Expected and actual behavior

Here is the request made from Swagger:

{ "ref_client": "DJELLAL1648", "socid": 44063, "date": 1705964400, "date-valid": 1705964400, "type": 0, "total_ht": 0.55, "total_ttc": 0.55, "lines": [ { "fk_product": 2, "qty": 1, "price": 0.55, "subprice": 0.55, "total_ht": 0.55, "total_ttc": 0.55, "multicurrency_subprice": 0.55, "multicurrency_total_ht": 0.55, "multicurrency_total_tva": 0.00000000, "multicurrency_total_ttc": 0.55 } ], "date_livraison": 1706223600, "shipping_method_id": 2, "contacts_ids": [ "20539" ] }

Request URL https:/url/dolibarr/htdocs/api/index.php/orders Response Body 232 Response Code 200

Someone can explain to me how i can fix it ?

Steps to reproduce the behavior

add an order with swagger api or any calls api, try to add an user contact : add this row in your form: "contacts_ids": [ "20539" // replace it with your id contact ],

it will done "response 200" but no change are done.

Attached files

No response

JonBendtsen commented 9 months ago

I see the same behaviour in 18.0.4 Tuxgasy container image.

I used this json

{
"ref_client": "DJELLAL1648",
"socid": 1,
"date": 1705964400,
"date-valid": 1705964400,
"type": 0,
"total_ht": 0.55,
"total_ttc": 0.55,
"lines": [
{
"fk_product": 40,
"qty": 1,
"price": 0.55,
"subprice": 0.55,
"total_ht": 0.55,
"total_ttc": 0.55,
"multicurrency_subprice": 0.55,
"multicurrency_total_ht": 0.55,
"multicurrency_total_tva": 0.00000000,
"multicurrency_total_ttc": 0.55
}
],
"date_livraison": 1706223600,
"contacts_ids": [
"380"
]
}

I tried POST an order /api/index.php/orders I tried PUT orderid /api/index.php/orders/ to update the order

and I could not see the contact id.

But I also tried POST /api/index.php/explorer/#!/orders/ordersCreateContact "Add a contact type of given order"

And that did work, the contact was added to the order

JonBendtsen commented 9 months ago

@Mohammed-el-Amine Have you tried my suggestion? using another API endpoint?

Mohammed-el-Amine commented 9 months ago

Sorry, i was so busy...

I use the same endpoint but i need to add anorher API call for add contact in the order.

Mohammed-el-Amine commented 9 months ago

First step : create order and save the ID Second step : use the ID of the order to add a contact .

in the same time it better maybe in the futur.