Custom DocType - Select 'Custom?' or Not

I have a custom app, i am in developer mode, and i created a custom doctype. If I leave the Custom? checkbox unchecked the system will automatically create the json, py and js files in the correct directory under my custom app. But if i leave it unchecked when accessing the Doctype I am prompted with an ImportError.

Example of error:

Traceback (innermost last):
  File "/home/strella/frappe-bench/apps/frappe/frappe/app.py", line 57, in application
    response = frappe.handler.handle()
  File "/home/strella/frappe-bench/apps/frappe/frappe/handler.py", line 19, in handle
    execute_cmd(cmd)
  File "/home/strella/frappe-bench/apps/frappe/frappe/handler.py", line 36, in execute_cmd
    ret = frappe.call(method, **frappe.form_dict)
  File "/home/strella/frappe-bench/apps/frappe/frappe/__init__.py", line 806, in call
    return fn(*args, **newargs)
  File "/home/strella/frappe-bench/apps/frappe/frappe/desk/form/save.py", line 12, in savedocs
    doc = frappe.get_doc(json.loads(frappe.form_dict.doc))
  File "/home/strella/frappe-bench/apps/frappe/frappe/__init__.py", line 534, in get_doc
    return frappe.model.document.get_doc(arg1, arg2)
  File "/home/strella/frappe-bench/apps/frappe/frappe/model/document.py", line 46, in get_doc
    return controller(arg1, arg2)
  File "/home/strella/frappe-bench/apps/frappe/frappe/model/document.py", line 82, in __init__
    super(Document, self).__init__(arg1)
  File "/home/strella/frappe-bench/apps/frappe/frappe/model/base_document.py", line 48, in __init__
    self.update(d)
  File "/home/strella/frappe-bench/apps/frappe/frappe/model/base_document.py", line 71, in update
    self.set(key, value)
  File "/home/strella/frappe-bench/apps/frappe/frappe/model/base_document.py", line 118, in set
    self.extend(key, value)
  File "/home/strella/frappe-bench/apps/frappe/frappe/model/base_document.py", line 144, in extend
    self.append(key, v)
  File "/home/strella/frappe-bench/apps/frappe/frappe/model/base_document.py", line 132, in append
    value = self._init_child(value, key)
  File "/home/strella/frappe-bench/apps/frappe/frappe/model/base_document.py", line 159, in _init_child
    value = get_controller(value["doctype"])(value)
  File "/home/strella/frappe-bench/apps/frappe/frappe/model/base_document.py", line 39, in get_controller
    raise ImportError, doctype
 ImportError: Issue Assigned To

However, if i proceed to check the Custom? checkbox, i can load the doctype successfully.

My question is, what is the correct procedure for creating custom doctypes and ensuring that the json, py and js files are updated as we are designing the form etc.? Should we or should we not check the Custom? checkbox?

1 Like

@bohlian Custom Doctypes are usually checked to mark the doctypes that are defined in Production mode, and don’t change the files on disk.

So if you are in developer mode, don’t use Custom Doctypes

@max_morais_dmm sorry, I dont quite get you, should I not use Custom Doctypes in developer mode?
or do you mean i should not use the Custom? checkbox?

Basically if I do not use Doctypes to create my new Doctype how else can i create the Doctype?

@bohlian, I’m refering about the checkbox Custom!

If you are in developer mode, dont check it, because your assets and schemas dont will be generated in the disk!

@max_morais_dmm ah ok!

So basically when we are developing the doctype we DONT check it so it will write the assets and schema to disk.

Once we are done developing, we ENABLE or check it so it can be used.

Let me know if i am wrong. Thanks man!

@bohlian, Developer mode enable you to disable the Custom checkbox.

1 Like

@max_morais_dmm yes i understand…

I am just curious, when you are creating the Doctype you disable the Custom checkbox, but when you want to test the form etc. you have to enable the Custom checkbox? So strange, I wonder why it is designed that way.

Thanks by the way for your explanation.

@bohlian, you dont need enable the custom checkbox! This is enabled by default when you are in Production mode.

1 Like

I have two separate environments (benches) one in Development mode and another in Production mode. I have my own CustomApp in Dev so that I add new DocTypes and push to GIT. The Production has this CustomApp installed from my GIT repository.

When I do $ bench update, in the Production, I always get error. I have to set the site to developer_mode; run bench update; then revert back from developer_mode to Production (i.e. developer_mode=0)

Note: I have custom? unchecked in all my new doctypes created in the CustomApp

Pls. confirm if what I do is right. Particularly - should I put my Production instance to Developer_mode for doing the bench update