Hello, can anyone tell me how can we add modules and doctype by code? like i do not want to add them by UI rather than by code. i have tried several ways but it keep giving me errors.
Hi @Madhav,
Code look like
doctype = frappe.get_doc({
"doctype": "DocType",
"module": "New Module", # The module where you want to add the DocType
"name": "Your DocType",
"is_submittable": 1,
"fields": [
{
"fieldname": "field_1",
"fieldtype": "Data",
"label": "Field 1"
},
# Add more fields as needed
],
"permissions": [
{
"role": "System Manager",
"read": 1,
"write": 1
},
# Add more permissions as needed
]
})
doctype.insert()
I hope this helps.
Thank You!
1 Like