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?
Thanks.

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/app.py”, line 56, in application
response = frappe.handler.handle()
File “/home/ubuntu/frappe-bench/apps/frappe/frappe/handler.py”, line 19, in handle
execute_cmd(cmd)
File “/home/ubuntu/frappe-bench/apps/frappe/frappe/handler.py”, line 42, in execute_cmd
ret = frappe.call(method, **frappe.form_dict)
File “/home/ubuntu/frappe-bench/apps/frappe/frappe/init.py”, line 907, in call
return fn(*args, **newargs)
File “/home/ubuntu/frappe-bench/apps/frappe/frappe/desk/form/load.py”, line 70, in getdoctype
docs = get_meta_bundle(doctype)
File “/home/ubuntu/frappe-bench/apps/frappe/frappe/desk/form/load.py”, line 81, in get_meta_bundle
bundle = [frappe.desk.form.meta.get_meta(doctype)]
File “/home/ubuntu/frappe-bench/apps/frappe/frappe/desk/form/meta.py”, line 22, in get_meta
meta = FormMeta(doctype)
File “/home/ubuntu/frappe-bench/apps/frappe/frappe/desk/form/meta.py”, line 32, in init
self.load_assets()
File “/home/ubuntu/frappe-bench/apps/frappe/frappe/desk/form/meta.py”, line 42, in load_assets
self.load_templates()
File “/home/ubuntu/frappe-bench/apps/frappe/frappe/desk/form/meta.py”, line 152, in load_templates
module = load_doctype_module(self.name)
File “/home/ubuntu/frappe-bench/apps/frappe/frappe/modules/utils.py”, line 182, in load_doctype_module
doctype_python_modules[key] = frappe.get_module(module_name)
File “/home/ubuntu/frappe-bench/apps/frappe/frappe/init.py”, line 672, in get_module
return importlib.import_module(modulename)
File “/usr/lib/python2.7/importlib/init.py”, line 37, in import_module
import(name)
File “/home/ubuntu/frappe-bench/apps/customapps/customapps/customapps/doctype/test2/test2.py”, line 11
Test_doc=frappe.new_doc(“test_doctype”)
^
IndentationError: expected an indented block
Home

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