def write_document_file(doc, record_module=None, create_init=None):
	newdoc = doc.as_dict(no_nulls=True)

	# strip out default fields from children
	for df in doc.meta.get_table_fields():
		for d in newdoc.get(df.fieldname):
			for fieldname in frappe.model.default_fields:
				if fieldname in d:
					del d[fieldname]

	module = record_module or get_module_name(doc)
	if create_init is None:
		create_init = doc.doctype in lower_case_files_for

	# create folder
	folder = create_folder(module, doc.doctype, doc.name, create_init)

	# write the data file
	fname = (doc.doctype in lower_case_files_for and scrub(doc.name)) or doc.name
	with open(os.path.join(folder, fname +".json"),'w+') as txtfile:
		txtfile.write(frappe.as_json(newdoc))
dataset/ETHPy150Open frappe/frappe/frappe/modules/export_file.py/write_document_file/original