Creating or updating document with children

there are times that doc.insert() alone does not work. Im still not sure how.

but as mentioned in this discussion Cant insert new documents from python scripts - #8 by max_morais_dmm

by doing the following:

doc.insert()
frappe.db.commit()

will save the data.