Value not setting in field with .py field

I am trying to set value to a field directly from.py file but getting error. I want to set it when new doc is opened. Any help ?

.py will not help here, use JS instead and set your field on onload

I was using this as a reference Frappe - Creating a Custom Application & Integrating it with ERPNext - YouTube

BTW isn’t it is possible if I write code in the .py file which gets created in doctype folder instead of manually creating.

Also, if writing in .py where .js exists, I am having issue with using it as method. Any help ?

Ok I think I replied too fast. .py file will not show a instantaneous change as far as i know, if you want instant changes use JS not python. I say this because this helps seperate the purpose of python and JS files in my opinion.

BTW isn’t it is possible if I write code in the .py file which gets created in doctype folder instead of manually creating.

Yes it will.

Also, if writing in .py where .js exists, I am having issue with using it as method. Any help ?

I cannot understand your question.