List of Hooks

Here’s a categorized list of hooks that can be defined in a Frappe application, based on typical usage:


Core Hooks

  1. app_name - Name of the application.
  2. app_title - Title of the application.
  3. app_publisher - Publisher of the application.
  4. app_description - Short description of the application.
  5. app_icon - Icon for the application.
  6. app_color - Primary color for the application.
  7. app_email - Support email for the application.
  8. app_version - Version of the application.
  9. required_apps - List of dependent Frappe apps.

DocType Hooks

  1. doctype_js - Map of JavaScript files for specific DocTypes.
    • Example: {'Sales Invoice': 'public/js/sales_invoice.js'}
  2. doctype_list_js - JavaScript for the list view of a DocType.
  3. doctype_tree_js - JavaScript for the tree view of a DocType.
  4. doctype_calendar_js - JavaScript for the calendar view of a DocType.
  5. override_doctype_class - Override the Python class for a DocType.
    • Example: {'ToDo': 'custom_app.overrides.CustomToDo'}

Document Events

  1. doc_events - Hooks for specific DocType events (CRUD operations).
    • Events: on_update, before_save, after_insert, on_trash, on_submit, on_cancel, etc.
    • Example:
      {
          "Sales Invoice": {
              "on_submit": "custom_app.events.sales_invoice_on_submit",
          }
      }
      

Scheduled Tasks

  1. scheduler_events - Define periodic tasks.
    • Example:
      scheduler_events = {
          "all": [
              "custom_app.tasks.all"
          ],
          "daily": [
              "custom_app.tasks.daily"
          ],
          "hourly": [
              "custom_app.tasks.hourly"
          ],
          "weekly": [
              "custom_app.tasks.weekly"
          ],
          "monthly": [
              "custom_app.tasks.monthly"
          ]
      }
      

Permission Hooks

  1. permission_query_conditions - Define custom permission conditions for a DocType.
  2. has_permission - Define custom logic to check if a user has access to a DocType.

Override Hooks

  1. override_whitelisted_methods - Override standard Frappe whitelisted methods.
    • Example:
      override_whitelisted_methods = {
          "frappe.desk.doctype.event.event.get_events": "custom_app.custom_event.get_events"
      }
      
  2. override_doctype_dashboards - Override the dashboard for a DocType.
  3. override_doctype_class - Replace the Python class of a DocType.

Notification Hooks

  1. notification_config - Define a custom notification configuration.
    • Example: notification_config = "custom_app.notifications.get_notification_config"

Custom Jinja Filters

  1. jinja - Define custom filters for Jinja templating.
    • Example:
      jinja = {
          "filters": "custom_app.utils.jinja_filters"
      }
      

Auth Hooks

  1. auth_hooks - Add custom authentication logic.
    • Example: auth_hooks = ["custom_app.auth.validate"]

Fixtures

  1. fixtures - Define DocTypes or customizations to export as fixtures.
    • Example:
      fixtures = [
          "Custom Field",
          "Property Setter"
      ]
      

Translation Hooks

  1. translated_search_doctypes - Specify DocTypes where translations should be searchable.

Page and Report Hooks

  1. page_js - JavaScript for specific pages.
  2. report_js - JavaScript for specific reports.

Website Hooks

  1. website_context - Add context for website rendering.
  2. update_website_context - Update global website context.

Other Miscellaneous Hooks

  1. on_session_creation - Logic to run when a user session is created.
  2. before_tests - Logic to run before tests are executed.
  3. task_fail - Logic to handle task failure.
  4. before_migrate / after_migrate - Logic to run during migration.
  5. user_data_fields - Define sensitive fields for data protection.

Discard
Save
This page has been updated since your last edit. Your draft may contain outdated content. Load Latest Version
Was this article helpful?

On this page

Review Changes ← Back to Content
Message Status Space Raised By Last update on