I am doing a POC for agriculture domain where I have created another app. In this app for agriculture, I have created a Daily Production doc type which stores production of various crops from different fields. For example there are 4 fields, two fields grow tomatoes and two grow onions.
For example, I harvested 2 kg and 3 kg tomatoes and 5 kgs and 7 kgs of onions from respective fields.
The data is entered in Daily Production doc type and when I save the data , I want to consolidate total daily production of tomatoes and onions respectively and create stock of 5kg tomatoes and 12 kgs of onions in ERPNext stocks.
Can someone please help me with some guidance on following:
How can we call the methods of doctype of another app from a custom built app and where to write the code to do that. Most probably, I believe in Controller of “Daily Production” Doctype. Hope I am right. But under which event method.
How can we maintain transactional integrity? i.e., if records does not gets created in ERPNext Stocks then it shall not get saved in Daily Production doctype also.
Because, it will be possible to loose entered data in the case when there are over 20 crops as it would take time for user to enter it and he may loose session or any other issue may occur. How can we let user save entered data automatically in draft mode. And give him a button to finally submit it and then system creates data in Daily Production doctype and ERPnext stocks also together.