I’m currently working on a large-scale Frappe app that includes around 400+ patches, most of which add or update Custom Fields in core doctypes such as Company and Employee.
All patches execute successfully — the new custom fields appear in the Custom Field list, and the tabCustom Field table in the database shows correct entries.
However, many of these fields do not reflect:
-
In the actual Doctype Form View, or
-
In the Customize Form view (some fields appear, some do not).
In certain cases:
-
A field appears in Customize Form but not on the actual form.
-
Some fields are completely missing in both, even though the DB shows them correctly.
What I’ve Already Tried
-
Verified that all patches are listed in show-patchesand executed successfully. -
Confirmed that tabCustom Fieldentries exist for each field with the correctdt,fieldname, andinsert_after. -
Cleared caches and reloaded doctypes multiple times:bench --site <site> clear-cache bench --site <site> clear-website-cache bench --site <site> migrate bench --site <site> reload-doc erpnext accounts company bench restart -
Tried resetting Customize Form and reloading metadata. -
Checked app load order and confirmed my custom app runs after erpnext. -
Added cache clear lines in patches (frappe.clear_cache(doctype="Company")). -
Manually reloading via console reflects the fields temporarily, but they disappear after a new build or migrate. -
Cleared from custom field list in Site
Observation
This seems to happen only with core doctypes (Company, Employee, etc.), not with custom doctypes created within my own app.
Custom fields added manually through the UI (Customize Form) appear correctly, but programmatically created ones (via patches) are not consistently merged into the DocType metadata cache.
In some instances, the fields load after a restart, but then vanish again once another migration or build runs — likely due to core JSON reload overriding the runtime metadata.
Questions
-
Is this a known issue where core doctypes ignore patch-based Custom Fields due to Frappe’s internal metadata caching or JSON reloading behavior?
-
What is the best long-term, update-safe approach when you have hundreds of programmatically added fields for core doctypes?
- Or is there a way to make patches “stick” permanently to core doctypes?
-
Is there a reliable command or API to force metadata rebuild for core doctypes so the fields merge properly after patch execution?
What I’m Looking For
-
A clear, Frappe-supported best practice for maintaining large-scale patch-based customizations on core doctypes.
-
Confirmation on whether fixtures are the only safe, persistent solution in this case.
-
Any internal mechanism or workaround (like an event hook or metadata rebuild command) to ensure custom fields persist reliably on core doctypes after every build/migrate.
Summary
Despite successful patch execution and visible entries in the Custom Field list, many programmatically added fields in core doctypes are not appearing in the actual form or customize form, suggesting a desync between database-level custom fields and Frappe’s metadata cache or JSON reload mechanism.
Would appreciate any guidance or official clarification on the proper, update-safe, and scalable method to manage hundreds of custom fields across core doctypes.