Extend / inherit existing Doctype from a custom app

I won’t start with extending/inhereting the doctype first. It’s a nightmare to maintain overridden code.

  1. If you need extra fields just add custom fields - https://docs.erpnext.com/docs/user/manual/en/customize-form and https://docs.erpnext.com/docs/user/manual/en/custom-field
  2. If you need some business logic on those extra fields:
    1. Use server scripts - Server Script OR
    2. Use doc_event hooks from app - Hooks
  3. If you STILL can’t achieve all the functionality then override the entire class - Hooks

In general, “prefer extending over overriding” and your customizations will be maintainable long term.

1 Like