Adding a doctype-controller manually

Hi there,
I have a doctype for which no boilerplate-code was created.
I added a py-file manually, but the controller-methods are never called.
This is my doctype:

I saved the controller-file as:

with this content:

import frappe
from frappe.model.document import Document

class ProjectEmployee3(Document):
    def validate(self):
        print("ProjectEmployee3: validate")

	def before_save(self):
        print ("ProjectEmployee3: before_save")

I expected to see the dialogboxes from frappe.throw() on saving a record in the doctype, but nothing happens.
web.log doesn’t also contain any messages.

The folder apps/erpnext/erpnext/projects/doctype/projectemployee3/ only contains this:

frappe@erpnextthkr:~/frappe-bench$ ls -l apps/erpnext/erpnext/projects/doctype/projectemployee3/
total 4
-rw-r--r-- 1 frappe frappe 397 Sep  9 16:00

I would also like to know why no boilerplate-code (js, json & py-files) was created.
Has anyone encountered this too?

1 Like

yeah, i have encountered this as well.

in my case, i had to disable custom? field on the doctype.

after that it generated the necessary boilerplate code.

Thank you. Meanwhile I discovered that it is unwise to put your own DocTypes into the ERPNext-Module. It’s much better to create a new application and put them in there without marking them as custom.

You can add scripting to custom DocTypes by using “Build > Client Script” or “Build > Server Script”.