Custom doctype missing after bench restore


I’ve used bench restore and found that most of my custom doctypes are missing.

Strangely, the doctypes are showing in doctype list, however they are unusable and throw the error below when trying to open them in list view.

Looking at the files in vscode, it seems like during the restore the folder structure isn’t created for them in apps>erpnext>erpnext>accounts>doctype. I’m able to fix this by editing the doctype (making some small change in the erpnext doctype gui) and then saving it. This then generates the file structures needed in the backend.

Does anyone have any experience with this problem? Am I missing a step to restore my custom doctypes correctly?

Error that pops up before doctype edited and folder structure generated.

### App Versions

	"erpnext": "14.0.0",
	"frappe": "14.0.0",
	"payments": "0.0.1"

### Route

List/Lease Agreement/List

### Trackeback

Traceback (most recent call last):
  File "apps/frappe/frappe/", line 69, in application
    response = frappe.api.handle()
  File "apps/frappe/frappe/", line 54, in handle
    return frappe.handler.handle()
  File "apps/frappe/frappe/", line 45, in handle
    data = execute_cmd(cmd)
  File "apps/frappe/frappe/", line 83, in execute_cmd
    return, **frappe.form_dict)
  File "apps/frappe/frappe/", line 1581, in call
    return fn(*args, **newargs)
  File "apps/frappe/frappe/desk/form/", line 74, in getdoctype
    docs = get_meta_bundle(doctype)
  File "apps/frappe/frappe/desk/form/", line 85, in get_meta_bundle
    bundle = [frappe.desk.form.meta.get_meta(doctype)]
  File "apps/frappe/frappe/desk/form/", line 45, in get_meta
    meta = FormMeta(doctype)
  File "apps/frappe/frappe/desk/form/", line 56, in __init__
  File "apps/frappe/frappe/desk/form/", line 66, in load_assets
  File "apps/frappe/frappe/desk/form/", line 121, in add_code
  File "apps/frappe/frappe/desk/form/", line 134, in add_html_templates
    for fname in os.listdir(path):
FileNotFoundError: [Errno 2] No such file or directory: 'apps/erpnext/erpnext/accounts/doctype/lease_agreement'

### Request Data

	"type": "GET",
	"args": {
		"doctype": "Lease Agreement",
		"with_parent": 1,
		"cached_timestamp": null
	"headers": {},
	"error_handlers": {},
	"url": "/api/method/frappe.desk.form.load.getdoctype"

### Response Data
	"exception": "FileNotFoundError: [Errno 2] No such file or directory: 'apps/erpnext/erpnext/accounts/doctype/lease_agreement'"

I’m also having a similar issue. For my custom app, when I pushed it to github for the first commit, I am missing one DocType and its child table DocType. When I run bench start and long into my site, the missing DocType appears in the DocType list under the correct module. I am able to modify the DocType and even create new records but this does not make it show up under the apps/my_app/my_app/doctype directory. It also does not appear under any untracked files and I only have one branch :frowning:

I moved all my custom doctypes to a new app. That solved the problems I described above.

Before I push to git or backup frappe I do a bench export-fixtures and bench migrate, you could try that?

I have a different situation because it is a standalone frappe app. There aren’t any custom doctypes on the site where my erpnext instance is running.

I figured I’d post my issue in this thread because the problem that is the same is the fact that not all the doctypes I have created are showing up in my directory but do show up in the gui.

I figured out what the problem was. For some reason I was logged in as a user (with full access to all the Modules) but I was not logged in as the Administrator username. So whenever I created a new DocType, even though Developer Mode was enabled, the Custom? checkbox was selected and so no boilerplate code was being created. This is the reason I could see my DocTypes in the GUI but not in the code.

I logged into my site with the Administrator username and I was then able to unselect Custom? when creating a new DocType and all is fixed.