Automated Stock Entry?

So this came up in a meeting, but the company I’m working for wants to automate the stock entry process for moving tested units from a processing warehouse to a shipping warehouse. Is there a way to do this via api call in python? I know we can make handlers in the and then make functions for automated emailing and the like.

Basically, it would have to look through the descriptions on individual serial numbers for a pass or fail flag to determine if it gets moved to shipping or not. Then generate a stock entry (material transfer) from the processing warehouse to the shipping one.

I’ve looked the section over in the documentation and was wondering: Does any part of the ERPNext system make use of the API? I was thinking of looking at those parts to see an example implementation. And thanks for the quick reply!

The API works in a similar fashion to the client side scripting with Basically you can access a whitelisted function through the API with either get/post, and the functions in frappe.client are built in.

If you’re working in Python, you can use frappe-client to create a session object and access the API that way, rather than using http requests.

Okay, that makes sense. I was wondering about why I wasn’t seeing any HTTP requests when browsing through the ERPNext stock module code.

The python code is running on the same server as the ERPNext and is ran using via the event_scheduler. At least that is the idea I’m working with.

That should work great - if it is also event driven and not time driven, you could use a hook to a document event (e.g. on submit).

If you get stuck, reach out - I’ve been working a lot with the API recently.

So quick question,

If I use the API call frappe.get_doc({ … }) and fill out certain fields, will the API autofill details that are left out such as price and UOM of an item code, or would I have to fetch all of that information manually when creating the document?

get_doc will fetch an already existing doc - but it returns the info as a json object / python dictionary. You should specify every field you want to fetch when you make the request in order to get those fields!