I had asked previously about …
… and @revant_one found me what I thought I needed.
It turns out only to be part of what I needed.
Taking purchase orders as an example i used the “desk” to set the starting sequence number for naming series PUR-ORD-.YYYY.-
to 987
.
I then created a purchase order and found that it correctly assigned it a document number of PUR-ORD-2020-00988
I then ran my API curl
command to examine the registered internal storage of that naming series…
curl -sX POST '${RPC_ENDPOINT}/runserverobj' \
-H "Authorization: token ${YOUR_TOKEN}" \
-H 'Content-Type: application/json' \
-d '{
"method": "get_options",
"docs": "{\"name\":\"Naming Series\",\"doctype\":\"Naming Series\",\"select_doc_for_series\":\"Purchase Order\",\"modified\":\"2020-05-20 21:26:31.389303\"}"
}' | jq -r .;
The result is:
{
"docs": [
{
"name": "Naming Series",
"modified": "2020-05-20 21:26:31.389303",
"idx": 0,
"docstatus": 0,
"select_doc_for_series": "Purchase Order",
"user_must_always_select": 0,
"current_value": 0,
"doctype": "Naming Series"
}
],
"message": "PUR-ORD-.YYYY.-"
}
It seems logical that current_value
should be 987, but it isn’t, and I don’t understand why not?
My actual requirement is to be able to specify some sequence starting numbers through the API, but the command that updates the possible series format templates for a DocType doesn’t appear to allow setting a start number at all:
cat << UPEOF > /dev/shm/SeriesUpdate.json;
{
"method": "update_series",
"docs": "{\"name\":\"Naming Series\",\"doctype\":\"Naming Series\",\"select_doc_for_series\":\"Webhook\",\"set_options\":\"\\\nHOOK-.####\\\nWHK-.####\",\"modified\":\"${DATE_MODIFIED}\"}"
}
UPEOF
cat /dev/shm/SeriesUpdate.json;
curl -sX POST "${RPC_ENDPOINT}/runserverobj" \
-H "Authorization: token ${YOUR_TOKEN}" \
-H "Content-Type: application/json" \
-d @/dev/shm/SeriesUpdate.json | jq -r .;
All you seem to be able to do is define the formatting templates with “set_options” …
"set_options": "\nHOOK-.####\nWHK-.####"
Is it possible to set the start number for a series by means of an RPC? If so, how?
Where might I find the code for the two RPC commands get_options
and update_series
?