How to Automate Stock Reconciliation?

Hello guys, im trying to get warehouse inventory from an external API (physical data) and compare it to my ERPNext warehouse inventory levels and then do either opening stock if item doesn’t exist or stock reconciliation otherwise,
i can easily get warehouse items levels using get_items

from erpnext.stock.doctype.stock_reconciliation.stock_reconciliation import get_items

and do the check up and opening stock and it works fine, however when trying to do stock reconciliation it doesn’t give any error and shows it succeeded, but no thing appears in stock reconciliation list and opening stock


even it says here 44

i also tried to do a stock entry (purpose: Material issue ) and sometimes works and sometimes disappers from list as it didn’t exist like stock reconciliation.
i noticed that it happens if any error happened during creating any doc weather stock entry ,stock reconciliation or opening stock .

which i believe is responsible for the total mess

here is the code i use for stock reconciliation and opening stock and stock entry



what could be the issue?

Chances are that you have a filter which is not letting you see the transactions. Try clearing filters. Check stock ledger report and see if you can see anything in the stock ledger report. Again clear filters when you do.

All these work wonderfully well on ERPNext. Please check: Your instance may have a problem or you are doing something wrong.

Hope this helps.

Thanks

Jay

what filters do you mean?, I believe there is no filters as shown above in the image?

to whomever interested , probably the solution to server time out issue is to catch any exception that occurs when/before saving any doc and use frappe.db.rollback() so it cancel any changes happened and let the doc be accessible again.