Explanation: I have 2 doctypes:- Doctype1 and Doctype2. Lets say, when I create a doc in Doctype1, based on information filled in Doctype1, I also want to create a doc in Doctype2. I require a solution to be in server script.
Problem: I am aware that inside of Doctype1.py file, I can use frappe.get_doc and pass the info for Doctype2 and then insert or save it with .insert() or .save().
But I want that Doctype2 creation only once Doctype1 is saved inside db.
@NCP Thanks for your reply.
As I mentioned earlier, I do know that I can use .get_doc and .save() to insert doctype2.
My problem is that…
Lets say I create a Doctype1, the execution goes something like this:
Creating (saving of doctype1 triggers doctype2.py) (as of now since content in this files are being executed doctype1 is not saved yet)
inside doctype1.py – code encounters doctype2.save() or .insert(), so it moves to doctype2.py
executed everything inside doctype2.py and saves it
then comes back inside doctype1.py and finally saves it also in db
So basically, trying to save doctype1 works in way that doctype2 saves in db first and then doctype1 save itslef in db. What I want is doctype1 should first save it in db and only then should move on to saving doctype2.