Need help on customization on .py file

Hi Guys,

I am first time do the customization on .py file.
I have minor problem on it. What i want is when ‘test2’ doctype been created. Some dummy data on another doctype called ‘test_doctype’ can be created also.

Below is my file.

Below is the test_doctype structure.

Below is the error.

By the way, i go to frappe-bench/log. there didn’t have any log related to investigate.
What action i should do to debug this kind of error?

Hi All,

I able to get the error log from js.

Below is the log. thanks.

Traceback (most recent call last):
File “/home/ubuntu/frappe-bench/apps/frappe/frappe/”, line 56, in application
response = frappe.handler.handle()
File “/home/ubuntu/frappe-bench/apps/frappe/frappe/”, line 19, in handle
File “/home/ubuntu/frappe-bench/apps/frappe/frappe/”, line 42, in execute_cmd
ret =, **frappe.form_dict)
File “/home/ubuntu/frappe-bench/apps/frappe/frappe/”, line 907, in call
return fn(*args, **newargs)
File “/home/ubuntu/frappe-bench/apps/frappe/frappe/desk/form/”, line 70, in getdoctype
docs = get_meta_bundle(doctype)
File “/home/ubuntu/frappe-bench/apps/frappe/frappe/desk/form/”, line 81, in get_meta_bundle
bundle = [frappe.desk.form.meta.get_meta(doctype)]
File “/home/ubuntu/frappe-bench/apps/frappe/frappe/desk/form/”, line 22, in get_meta
meta = FormMeta(doctype)
File “/home/ubuntu/frappe-bench/apps/frappe/frappe/desk/form/”, line 32, in init
File “/home/ubuntu/frappe-bench/apps/frappe/frappe/desk/form/”, line 42, in load_assets
File “/home/ubuntu/frappe-bench/apps/frappe/frappe/desk/form/”, line 152, in load_templates
module = load_doctype_module(
File “/home/ubuntu/frappe-bench/apps/frappe/frappe/modules/”, line 182, in load_doctype_module
doctype_python_modules[key] = frappe.get_module(module_name)
File “/home/ubuntu/frappe-bench/apps/frappe/frappe/”, line 672, in get_module
return importlib.import_module(modulename)
File “/usr/lib/python2.7/importlib/”, line 37, in import_module
File “/home/ubuntu/frappe-bench/apps/customapps/customapps/customapps/doctype/test2/”, line 11
IndentationError: expected an indented block

You have error on Indentation please go through python programming syntax before customizing any .py file.

1 Like

To indicate a block of code in Python, you must indent each line of the block.

you missed indentation after on_update method.

It will be like,

class test2(Document):
	def on_update(self):
		Test_doc = frappe.new_doc("test_doctype")
		Test_doc.test = "testing"

One more thing if you want to insert new document on insertion of another use after_insert hooks

check Hooks for details.
on_update will create new record on every updation of document test2

1 Like

thanks @hereabdulla and @sangram it solved my problem. i will go study python syntax first.

1 Like