Sub Doctype Implementation

Is there way where I can implement a sub doctype? Its like this Doctype A will create Doctype B and Doctype B will create Doctype C.

so there are 2 potentials questions here - sub doctypes and creating doctype on other doctype creation

afaiu frappe has concept of child doctypes which are sort of tables which you can attach to your (parent) doctype(s) (ref: https://frappeframework.com/docs/v13/user/en/basics/doctypes/child-doctype)

for the “creating doctype on doctype creation” - you can use hooks (specifically the doc_events hook [ref: https://frappeframework.com/docs/v13/user/en/python-api/hooks#crud-events]). Basically Doctype is also a Doctype so you can create a doctype using frappe.get_doc utility (ref: https://frappeframework.com/docs/v13/user/en/api/document#frappeget_doc) easily (I know this is a bit doozy :slight_smile: )
also to know about various doc events -> https://frappeframework.com/docs/v13/user/en/basics/doctypes/controllers#controller-hooks

edit: you can also achieve the same from the UI itself using server scripts (the logic will remain the same) - ref: https://frappeframework.com/docs/v13/user/en/desk/scripting/server-script

PS: beware that if you write something like after_insert of a doctype to create another doctype …it will also trigger that after_insert hook for the “another” doctype and so on and if you don’t provide some sort of conditional check, the db will be flooded with doctypes :laughing: in this infinite loop.