We are creating a simple app to handle operations and part tracking on the floor of a production facility.
We have the API working and can create a new production order by specifying a part number. The problem is, that the production order that is generated does not have the default BOM that has been configured for that item.
Is there something we are doing wrong?
It probably doesn’t populate properly just from the python server-side code. Here’s how it does it in the client side:
I’d suggest using the api to find the default BOM for the item and plug it in “manually” when first creating the production order. The flag is
is_defaultin BOM, so you can just filter for item and is_default, and you should be fine.
Thank you for the information. The odd part is that using the API to create a production order REQUIRES a BOM to be specified, or it generates an error. We have hard coded a valid BOM and that number shows up in the production order on the ERPnext web interface correctly. However, the BOM operations data is not populated.
I don’t think you can call this method from the REST API (it’s not whitelisted), but maybe give it a try anyways. Alternatively, you can create a whitelisted function (in a custom app) that calls this function for your production order before submitting it.
Thanks again! That at least confirms we are doing things correctly and it is a limitation of the API. We are not able to use non-Public methods with the REST API unfortunately. The custom app is probably the easiest workaround. Manually (via code) parsing the BOM for the operations and populating the correct fields in the production order would require overhead that makes it kludgy and impractical.
Is there some way to request a change that makes it possible to tell the operations to be populated from the BOM via the API?
Here is the whitelisted method you’d need. I’ve created a pull request to add it to the core code so you don’t have to use a custom app (but it may take a while to get accepted).
po = frappe.get_doc('Production Order', name)
This was merged. Should be out in the next day or so…
Thank you very much for following up! I got pulled away on other projects. I will try it out in the next couple weeks and see if it works for us. We are putting out ERP integration on hold while we develop some other parts of our product.