But after I queried them again via the REST API, I noticed that their status was actually still Draft. Moreover, if I switched to the Report View, the status was displayed as Draft.
Can you make a GET API call for the document created and check the status returned in the response?
I have a feeling somehow db.commit is not executed when you create a document using POST method even if you send docstatus = 1 , you may have to update the status using UPDATE method in subsequent call if required.
response = login_session.put(
f"{po_endpoint}/{po_id}",
json={"status": 'To Receive and Bill'}
)
This was not possible and I got an HTTP 417.
@avc thank you for your feedback as well. I will watch the video after sending the message. I already tried your suggestion. I executed the following POST request:
However, I don’t even know what would be the correct status.
I would assume that there is some kind of an ENUM somewhere, explicitly defining the states a Purchase Order can be in but I wasn’t able to find it in the erpnext source code.
Manually updating the status or a Purchase Order worked by using the whitelisted method:
update_status_method_endpoint = f'{erpnext_url}/api/method/erpnext.buying.doctype.purchase_order.purchase_order.update_status'
pr_data = {
"status": "To Receive and Bill",
"name": po_id
}
response = login_session.post(update_status_method_endpoint, json=pr_data)
assert response is not None
assert response.status_code == 200
However, I still don’t understand the inconsistent status visualization in List View and Report View. Moreover, I was expecting that Purchase Orders would be submitted correctly on HTTP POST by providing docstatus:1 during creation, at least this is what the community has tough me.
Note that status is different that docstatus
Use submit method as suggested above.
I am aware of this, thank you
And, I already tried suggestion regarding:
POST https://yoursite.com/api/resource/Purchase%20Order/PUR-ORD-2024-00012
{
“run_method”: “submit”
}
Unfortunately, I was not helping in my case.
Moreover, regardless of the correct follow up method to the initial POST request to create the Purchase Order, the main question still is, why are List View and Report View showing different things in their respective Status column?