Introducing a new way to review your PRs.

Read the announcement

frappe / crm

Fully featured, open source CRM

View on GitHub

24 documents · Updated Nov 23, 2026

docs / crm-configuration-and-metadata

CRM configuration and metadata

CRM configuration and metadata define the records, choices, screens, dashboards, and site-wide behavior that make the CRM product consistent across tenants. DocType definitions describe the business data model, while seeded records, layouts, scripts, hooks, dashboards, and migration patches adapt that model for user work and for optional integrations. See CRM service platform for the wider Frappe application layer, CRM record management for record lifecycles, and API and event services for the server operations that use this configuration.

Configuration model

The configuration model has two parts: stable DocType metadata and site data that can be changed by an administrator. The first part defines valid fields and links. The second part supplies status names, filters, navigation items, layouts, scripts, dashboards, and settings that shape the product experience.

Configuration areaProduct role
CRM DocTypesDefine leads, deals, organizations, and supporting records such as statuses, sources, industries, territories, and lost reasons.
FCRM SettingsHold global behavior, branding, currency, calendar, communication, and navigation settings for one site.
CRM Global SettingsStore per-DocType JSON metadata for quick filters and sidebar items.
CRM View SettingsStore user and public list, group-by, and kanban views for a DocType.
CRM Fields LayoutStore the field arrangement for quick entry, side panels, data views, grid rows, and required fields.
CRM Form ScriptStore enabled client behavior for a DocType form or list view.
CRM DashboardStore role defaults and private user layouts for the CRM home page.
Insights workbookProvide standard CRM charts and measures for sales and service review.
Install and migrate hooksCreate safe defaults and move existing sites to newer configuration formats.

This split lets the product ship a useful default experience without making every site use the same operational choices. Site records remain the source for admin changes, while standard records and hooks provide a path for new product defaults.

CRM DocType definitions

CRM DocTypes are the schema layer for the product. A DocType is a Frappe record definition that names fields, links, child tables, required values, permissions, and presentation hints; lead and deal records then use those links to refer to shared metadata instead of storing free-form choices. The main definitions are CRM Lead in crm/…/crm_lead.json and CRM Deal in crm/…/crm_deal.json.

The lead and deal schemas connect the main sales records to the configuration records below:

  • CRM Lead Status and CRM Deal Status supply the required lifecycle status.
  • CRM Communication Status supplies the communication state, with Open as the default.
  • CRM Lead Source, CRM Industry, and CRM Territory supply reusable classification and ownership data.
  • CRM Lost Reason records why a lead or deal was lost. The Other choice requires notes.
  • CRM Fields Layout and CRM Form Script control how the same fields appear and behave in the client.

The schema also carries optional product, service-level, enrichment, and integration fields. These fields allow downstream systems to add context without changing the basic lead and deal relationship model. The lead controller applies the linked metadata at record time: it chooses an available open status when the named default is absent, requires loss data for lost states, and carries a custom lead field into a converted deal only when one matching custom deal field is unambiguous. When a lead links to an existing enriched organization, the controller fills empty enrichment fields without replacing user data. See CRM record management for the record lifecycle that uses these definitions.

References: crm/…/crm_lead.json• L80-188 crm/…/crm_lead.json• L239-480 crm/…/crm_deal.json• L86-170 crm/…/crm_deal.json• L177-518 crm/…/crm_lead.py• L117-170 crm/…/crm_lead.py• L280-306 crm/…/crm_lead.py• L341-417 crm/…/crm_lead.py• L589-621

Status metadata

Status metadata turns a display label into a lifecycle state that the product can group and report. Lead and deal statuses each have a unique name, an ordered position, a color, and a type such as Open, Ongoing, On Hold, Won, or Lost; deal statuses also carry a probability used for sales forecasting.

Fresh installs seed a default path from early qualification to a completed or lost outcome. The seed step only adds a status when its name does not exist, so an administrator's renamed or edited status is not replaced during a normal install or migrate.

Status familyDefault path
LeadNew, Contacted, Nurture, Qualified, Converted, Unqualified, Junk
DealQualification, Demo/Making, Proposal/Quotation, Negotiation, Ready to Close, Won, Lost
CommunicationOpen, Replied
AvailabilityActive, Away, Unavailable

Availability status is user metadata rather than a lead or deal stage. It records whether a CRM user can receive work and supports assignment behavior and the user's visible availability state. The migration adds the default availability records and the related fields on User for existing sites.

Migration patches also normalize older status records. They map known historical labels to the current status types and fill deal probabilities when those values are absent. This keeps older sites aligned with the current lifecycle semantics without changing values that already carry an explicit setting. The status DocTypes define the allowed type values and the fields that downstream list, kanban, and forecast views rely on.

References: crm/…/crm_lead_status.json• L15-46 crm/…/crm_deal_status.json• L16-51 crm/…/crm_communication_status.json• L11-19 crm/install.py• L40-159 crm/install.py• L568-609 crm/…/add_availability_statuses.py• L1-6 crm/…/update_lead_status_type.py• L4-59 crm/…/update_deal_status_type.py• L4-44 crm/…/update_deal_status_probabilities.py• L4-24

Dropdown and classification records provide controlled choices that users can manage in the CRM workspace. They are records rather than hard-coded values in lead and deal forms, which lets a site add business-specific sources, industries, territories, and loss reasons while keeping links valid.

The install process seeds common industries and lead sources. It also seeds loss reasons with descriptions that support consistent reporting. The workspace exposes these records under its metadata area, together with status and territory lists, so an administrator can maintain the choices that users see.

CRM Territory is a tree. Its parent relationship and group flag support a hierarchy that can also drive sales visibility when that feature is enabled. CRM Industry, CRM Lead Source, and CRM Lost Reason use unique names as their business values. This makes a linked value stable when records move through the lead and deal flows.

References: crm/…/crm_industry.json• L1-27 crm/…/crm_lead_source.json• L1-36 crm/…/crm_lost_reason.json• L1-34 crm/…/crm_territory.json• L1-92 crm/install.py• L368-495 crm/…/frappe_crm.json• L27-130

Call records

CRM Call Log is the activity record for phone work linked to CRM records. It represents incoming or outgoing calls across manual and provider-based telephony, keeps the call status and recording reference, and can connect the call to a lead, deal, task, or note. The call view resolves only related records that the current user may read.

The record also supports lead capture from a call. A permitted user can create a lead from call details, then the system links the new lead back to the call so the activity remains part of the same customer history. Completed outgoing calls also update the linked record's outbound interaction time. Recordings stored on the site play directly, while external recordings use the recording access service.

References: crm/…/crm_call_log.py• L50-155 crm/…/crm_call_log.py• L197-259 crm/…/crm_call_log.py• L261-311 crm/…/crm_call_log.py• L305-356 crm/…/test_crm_call_log.py• L68-85 crm/…/test_crm_call_log.py• L415-437

Task records

CRM Task is the follow-up record for work assigned to a user. It can stand alone or point to a lead or deal, and its status, priority, due date, and assignment make it usable in record pages, calendars, and the home dashboard.

An all-day task represents a calendar day rather than a time instant. The product keeps that day stable across time zones, while timed tasks use the user's local time to decide when they are due. Open tasks linked to leads or deals count as follow-ups; completed and canceled tasks do not.

The task system supports two reminder paths. A timed follow-up can create an in-product reminder shortly before its due time, while all-day follow-ups appear in the morning digest instead. This keeps the task field model aligned with both immediate notifications and daily work summaries.

References: crm/…/crm_task.json• L10-106 crm/…/crm_task.py• L36-67 crm/…/rules.py• L4-31 crm/…/rules.py• L42-108 crm/…/reminders.py• L19-77

User invitations

CRM Invitation is the short-lived record that turns an administrator's invitation into a CRM user. It holds the invitee, target CRM role, sender, acceptance state, and one-time key. A new invitation validates the email and starts in Pending; the key is cleared after acceptance, and old pending invites become expired after three days.

The invitation role controls who may create the invite and which CRM access the recipient receives. A System Manager can invite any supported role, while a Sales Manager can invite only a Sales User. Acceptance creates a system user when needed or updates an existing user that has no role profile. The selected role receives its inherited CRM roles, a new sales user is placed in the CRM module, and joining CRM users receive the Flow role when Flow is available.

Acceptance is limited to pending invitations and cannot reuse the key. New users are sent through password setup, while existing users must sign in before the invitation is accepted through the public invitation flow. These rules keep role assignment, account creation, and invitation links within one controlled onboarding path.

References: crm/…/crm_invitation.py• L29-43 crm/…/crm_invitation.py• L62-123 crm/…/crm_invitation.py• L126-145 crm/…/test_crm_invitation.py• L23-91 crm/…/test_crm_invitation.py• L105-163 crm/…/test_crm_invitation.py• L177-250 crm/hooks.py• L312-322

Notification records

CRM Notification stores an in-product message for one recipient. Its metadata identifies the sender, notification type, read state, message, and an optional dynamic reference to any DocType record. The supported types cover mentions, assignments, tasks, WhatsApp, automation, replies, and reminders.

Notification access is part of the application permission model rather than a simple public list. The hooks apply a query filter and a per-record permission check so users see notifications that belong to their CRM access scope. A change also publishes a realtime event so the recipient can refresh the visible notification state.

References: crm/…/crm_notification.json• L25-115 crm/…/crm_notification.py• L32-60 crm/hooks.py• L134-148

Global settings

FCRM Settings is the single site record for behavior that affects many CRM screens and records. It groups product controls for forecasting, sales hierarchy permissions, deal values, communications, timeline display, currency, exchange rates, calendar reminders, branding, navigation, onboarding state, and the morning digest. Its definition is in crm/…/fcrm_settings.json.

Several settings change other metadata when an administrator saves them. Enabling forecasting adds forecast fields to deal layouts and makes expected closure date and expected deal value required. Disabling it removes those layout sections and required rules. Once a CRM currency is set, the currency field becomes read-only. These changes keep the visible form and the validation rules aligned with the selected product mode.

The morning digest setting controls a daily summary for sales users. It is enabled by default for new sites, and a migration explicitly enables it for older sites so existing installations receive the same product behavior. Settings also owns the table of dropdown items used by the application shell. Standard items come from the app hook and are synchronized after migration. The settings document protects those standard entries from deletion, while still allowing site-specific entries and hidden items.

References: crm/…/fcrm_settings.json• L39-238 crm/…/fcrm_settings.py• L46-113 crm/…/fcrm_settings.py• L168-214 crm/…/enable_morning_digest.py• L1-6 crm/hooks.py• L404-457

Navigation metadata describes actions shown in shared CRM menus. CRM Dropdown Item is a child record with either a route or a separator, plus a label, icon, visibility flag, and new-window behavior. Standard items identify app selection, settings, Frappe Cloud login, about, a separator, and logout.

The install path copies standard items from the app hook into the FCRM Settings table. Later migrations add new standard items and remove standard items that the hook no longer declares. Custom items are not treated as standard, so the sync does not remove them.

References: crm/…/crm_dropdown_item.json• L18-80 crm/install.py• L517-529 crm/…/fcrm_settings.py• L188-214 crm/hooks.py• L412-457

View and form metadata

View and form metadata lets the same DocType support several user tasks without creating separate schemas. CRM Fields Layout stores JSON that groups fields into tabs, sections, and columns for quick entry, side panels, data fields, grid rows, and required fields. CRM Form Script stores JavaScript that adds client actions to a form or list view.

The layout service uses a saved layout when one exists. Otherwise it builds a layout from the DocType field order. It normalizes older flat layouts into a tab structure, removes fields that are not in the target DocType, and filters the result through the user's field permissions. It marks readable but non-writable fields as read-only and hides fields with no access. The client then turns the resulting field metadata into the matching input control. It applies linked records, child tables, choices, dates, numeric values, attachments, and rich text through a common form surface. This makes a shared layout safe for users with different roles while keeping each field type usable.

Field metadata also controls dependent visibility, required state, and read-only state. Active form rules can adjust these properties for a particular record, and the client applies those changes before displaying the field. Field changes then flow back to the owning document so that layouts remain a view of the same record rather than a separate data store.

The field surface also supports more than a standard saved document. Normal records bind changes to the active document, standalone layouts update supplied data without document scripts, and child-table rows receive parent and row-specific field overrides. This keeps one metadata contract usable across full forms, compact views, and reusable layout controls.

The client uses the following layout roles:

  • Quick Entry supports create dialogs.
  • Side Panel supports compact record detail views.
  • Data Fields supports the main editable field area.
  • Grid Row supports child-table rows.
  • Required Fields adds required fields that are not already visible.

References: crm/…/crm_fields_layout.json• L1-45 crm/…/crm_fields_layout.py• L29-109 crm/…/crm_fields_layout.py• L112-191 crm/…/crm_fields_layout.py• L194-259 frontend/…/Field.vue• L400-449 frontend/…/Field.vue• L456-573 frontend/…/Field.vue• L672-684

Saved views

Saved views preserve a user's way to read a DocType without changing the DocType itself. CRM View Settings supports list, group-by, and kanban views with filters, rows, columns, sort order, grouping, and route information. A view can be private, public, pinned, or the user's default for one DocType.

The view service fills missing rows and columns from the DocType controller's standard list data. For kanban views, it can also build columns from the selected link or select field. When a user sets a view as default, the service clears the old default only for that user and DocType. Public views require manager-level access, while private views remain editable by their owner or an administrator.

This keeps saved views compatible with evolving DocType metadata. A standard list definition supplies a useful starting point, while the saved view retains user choices instead of creating a second record schema.

References: crm/…/crm_view_settings.py• L46-119 crm/…/crm_view_settings.py• L151-197 crm/…/crm_view_settings.py• L200-288 crm/…/test_crm_view_settings.py• L31-46 crm/…/crm_lead.py• L447-523

Default layouts

Default layouts give new sites a consistent editing path for leads, deals, contacts, organizations, addresses, calls, notes, and tasks. The install seeder creates quick-entry, side-panel, and data-field layouts as named records. It skips existing layouts unless an explicit restore operation asks it to replace them.

Migration patches extend this policy to existing sites. One patch creates missing lead and deal side panels. Another converts older layout JSON to the newer tab and section shape. A layout repair patch converts legacy field objects inside saved columns into field names, so layout readers can resolve them as current DocType fields. Enrichment patches add company description and social fields to layouts only when those fields are missing. The address patch changes only the untouched original layout, which protects an administrator's custom arrangement. A later patch adds the all-day task field beside the due date in the quick-entry layout without replacing the rest of that layout.

This process means layout changes can reach old sites without silently overwriting local choices. A field added to a DocType still needs a layout or a fallback path before users can see it in a particular view.

References: crm/install.py• L162-266 crm/…/create_default_sidebar_fields_layout.py• L6-68 crm/…/update_layouts_to_new_format.py• L8-101 crm/…/normalize_layout_field_entries.py• L1-41 crm/…/add_enrichment_fields_to_layouts.py• L1-79 crm/…/reorder_address_quick_entry_layout.py• L37-59 crm/…/add_all_day_to_task_quick_entry.py• L5-26

Form scripts

Form scripts provide configurable client behavior that belongs beside a DocType's layout. An enabled script can apply to a form or list view, and the script lookup returns the active script for the requested DocType and view. Standard scripts are app-owned; users can change whether they are enabled, but editing their content requires developer mode.

The install path creates standard scripts for product totals on leads and deals and for deal forecasting. The product script keeps line totals and discounts in step with product rows. The forecasting script updates deal probability from the selected deal status. These behaviors connect metadata choices to calculated values without changing the core DocType schema. Field rendering also honors script-provided field property changes, so a form script can change how a field is shown or whether it can be edited for the current record.

References: crm/…/crm_form_script.json• L17-64 crm/…/crm_form_script.py• L25-56 crm/install.py• L532-537 crm/…/crm_products.py• L91-193 crm/…/fcrm_settings.py• L217-247 frontend/…/Field.vue• L461-560

Dashboard and analytics metadata

Dashboard metadata turns the same lead, deal, task, and interaction data into role-aware work views and standard sales reports. The home dashboard is user-configurable, while the Insights workbook provides a shared view of pipeline and outcome measures.

Home dashboard

The home dashboard stores a validated list of widgets with their position and display settings. An agent's default view focuses on tasks and sales value. A manager's default adds team workload and team reply views. Users can choose Lead, Deal, or Both for supported widgets, and managers can add time periods and shared filters where the widget supports them.

The dashboard uses two related scopes. The personal scope shows records owned by or assigned to the current user. The team scope follows the user's sales hierarchy, or all enabled sales users when the user has unrestricted manager access. Manager-only widgets are removed from agent layouts, and invalid widget names, settings, duplicate widgets, and positions are rejected before a layout is saved.

The Brief gives these layouts a work queue rather than only a set of counts. It highlights replies that need attention, due follow-ups, records with no next step, new records, unassigned work, and team workload. Recent activity combines views, messages, comments, notes, tasks, calls, assignments, and updates into one latest-action list, then removes records the user can no longer read. Reply channels are derived from the latest inbound email or WhatsApp message, including a deal's source lead when the lead was converted.

The dashboard can also start a Flow chat when Flow is enabled and the user can create a Flow session. The chat uses an approval mode that requires the user to approve requested actions. This connects guided work to the same role and access model as the rest of CRM.

References: crm/…/home_layout.py• L12-71 crm/…/home_layout.py• L133-220 crm/…/home_scope.py• L11-67 crm/…/home_widgets.py• L19-35 crm/…/brief.py• L276-338 crm/…/brief.py• L392-506 crm/…/recent_activity.py• L31-129 crm/…/reply_channel.py• L11-35 crm/…/ask_flow.py• L7-29

Sales analytics workbook

The standard CRM Insights workbook provides shared charts for lead volume, deal volume, pipeline stages, funnel conversion, sales trends, forecasted revenue, sources, territories, sales users, and lost deal reasons. Its queries join the lead and deal records to status and user metadata so charts use business labels rather than raw identifiers.

The workbook expresses money in base currency and uses deal status types for measures such as ongoing, won, lost, and forecasted value. It is therefore a consumer of status names, probabilities, exchange rates, closure dates, and owner fields. Changes to those contracts can change reports even when the record forms still save correctly.

References: crm/…/crm.json• L1-64 crm/…/crm.json• L263-371 crm/…/crm.json• L1268-1491 crm/…/crm.json• L1550-1803

Installation and migration lifecycle

Installation and migration hooks turn code-defined defaults into site configuration. A fresh install runs after_install, while a migration runs the ordered patch list and then the app's after_migrate handlers. The shared seed functions are designed to be idempotent: they add missing defaults and leave existing administrator data in place unless a specific restore action is used.

The lifecycle has three broad stages:

  1. Schema stage: Frappe syncs DocType definitions and makes the fields and links available.
  2. Data stage: install functions create default statuses, classification values, layouts, custom fields, scripts, dashboards, and enrichment rules.
  3. Repair stage: migration patches update old records, convert formats, add availability metadata for existing users, add all-day task layout data, backfill interaction timestamps, migrate legacy WhatsApp data when its optional app is present, enable the morning digest for existing sites, and grant the Flow role to eligible sales users. The after_migrate hooks then refresh standard scripts, roles, enrichment defaults, web-form fields, and navigation data.

The availability migration seeds Active, Away, and Unavailable only when those records do not exist. It also adds the CRM availability link and audit fields to User only when they are missing. This lets assignment behavior use the same metadata on upgraded sites as on fresh installs without replacing local status records.

Interaction backfills rebuild the last inbound and outbound times from email and, when the WhatsApp table exists, submitted WhatsApp messages. They carry lead interaction times to the latest deal created from that lead and then set the waiting-for-reply marker. This gives upgraded sites the same dashboard and response behavior as sites that recorded these timestamps from the start.

The final migration patch backfills the internal seen marker on older leads and deals. It treats those records as already seen by enabled users with CRM roles, plus Administrator, because the product cannot reconstruct view history from before seen tracking was enabled. New or changed records can then represent current unvisited work instead of making every old record appear unread.

This diagram shows how code-defined metadata becomes site behavior while preserving local configuration where the seed rules allow it.

flowchart TD
    A[DocType definitions] --> B[Schema sync]
    B --> C{Fresh install?}
    C -->|Yes| D[after_install seeds defaults]
    C -->|No| E[Ordered migration patches]
    E --> F[after_migrate refreshes defaults]
    D --> G[Site metadata and settings]
    F --> G
    G --> H[CRM forms, lists, menus, dashboards, and workflows]

The patch list separates work that must happen before model sync from work that needs the new model after sync. Pre-model patches move data before a DocType rename or removal. Post-model patches create fields and layouts, update status metadata, repair records that depend on the current schema, normalize saved layout entries, backfill interaction and seen state, and align existing users with new CRM features.

References: crm/hooks.py• L100-110 crm/hooks.py• L404-410 crm/install.py• L14-43 crm/install.py• L568-609 crm/patches.txt• L1-46 crm/…/add_all_day_to_task_quick_entry.py• L8-26 crm/…/backfill_interaction_timestamps.py• L13-69 crm/…/backfill_whatsapp_interaction_timestamps.py• L3-17 crm/…/enable_morning_digest.py• L1-6 crm/…/give_sales_users_flow_role.py• L7-17 crm/…/add_availability_statuses.py• L1-6 crm/…/normalize_layout_field_entries.py• L1-41 crm/…/set_seen_for_existing_deals_and_leads.py• L8-46 crm/…/session.py• L4-5 crm/…/migrate_from_frappe_whatsapp.py• L32-59

WhatsApp migration

The WhatsApp migration moves history from the former frappe_whatsapp records into the current WhatsApp records used by CRM. It runs only when the optional WhatsApp app and its old message record exist, so sites without that app keep the normal migration path.

The migration preserves the customer conversation model across the app change. It carries accounts, settings, templates, messages, replies, media references, and message links into the current records, then links existing WhatsApp profiles to matching CRM entities. It skips records that already exist and can run again when a site adds the WhatsApp app after CRM installation.

The migration also protects downstream behavior. It maps old message and template states to the current values, inserts historical messages without sending them again, refreshes caches, and updates references from files, comments, and notifications. A separate profile-link step adds missing links without removing existing ones, so old conversations become visible from the same CRM records as new conversations.

References: crm/…/migrate_from_frappe_whatsapp.py• L9-59 crm/…/migrate_from_frappe_whatsapp.py• L61-140 crm/…/migrate_from_frappe_whatsapp.py• L143-209 crm/…/link_existing_whatsapp_profiles_to_crm.py• L9-19 crm/…/link_existing_whatsapp_profiles_to_crm.py• L21-71 crm/install.py• L20-30 crm/patches.txt• L28-36

Application hooks

Application hooks connect the metadata model to shared product behavior. They register access rules for core CRM records, document events that update CRM state, automation events that flows can use, and scheduled jobs that maintain time-based records such as invitations, reminders, and saved views.

The hook catalog also defines the product's standard navigation items and the post-migration refresh steps. A change to a record, event, role, or menu contract therefore affects both the site configuration and the services that consume it.

References: crm/hooks.py• L138-224 crm/hooks.py• L240-333 crm/hooks.py• L404-457

Custom field extensions

Installation and migration also extend standard Frappe or integration DocTypes when CRM needs a cross-system contract. The extensions add CRM publishing and hidden-default data to Web Forms, lead creation from incoming email to Email Account, and enabled/reference fields to Email Template. Optional ERPNext support adds links between CRM deals, CRM products, and ERPNext customers or items only when the integration is enabled.

These fields are not part of the CRM DocType files because their owners are standard or external DocTypes. The install functions check for existing fields before creation and clear the affected DocType cache after changes. This keeps optional features from changing sites that do not use them.

References: crm/install.py• L279-365 crm/…/create_custom_fields_for_erpnext_in_crm.py• L1-18 crm/…/create_custom_fields_for_product_item_sync.py• L1-35 crm/patches.txt• L23-29

Change checklist

When these files or sections are changed, remember to consider these:

  • When a field is added to CRM Lead or CRM Deal, check every affected Quick Entry, Side Panel, and Data Fields layout. The client may otherwise fall back to a generated layout or omit the field.
  • When a status type or status name changes, check status seed data, probability updates, forecasting behavior, analytics workbook queries, and any API or client grouping that uses the type.
  • When availability status names or user availability fields change, check assignment rules, user validation, audit fields, and both fresh-install and migration seed paths.
  • When a standard navigation item changes in hooks.py, check the FCRM Settings synchronization rules. Keep standard names stable if existing sites must retain their saved menu state.
  • When a custom field targets a standard or ERPNext DocType, check the feature gate and cache refresh path. Sites without that dependency must still migrate safely.
  • When layout JSON changes shape, add a migration path for saved layouts. Existing site records are not automatically replaced by the default layout seeder.
  • When layout field entries change from objects to names or another shape, check every reader and writer of the saved JSON. A patch must preserve valid field names and skip malformed data without breaking migration.
  • When a standard form script changes, check its seeded name, enabled state, and the DocType/view pair used by the script lookup.
  • When field property overrides or field rendering rules change, check standalone layouts, normal documents, child-table rows, permission filtering, and dependent visibility or read-only behavior. These paths must keep the same field metadata contract.
  • When the seen marker or its user scope changes, check the migration backfill and the role set used to identify enabled CRM users. Existing records must not appear unvisited because their history cannot be reconstructed.
  • When a default seeder changes, decide whether the change belongs in after_install, after_migrate, or an explicit patch. Do not rely on a skip-if-exists seeder to update old site records.
  • When a controller's default list rows or columns change, check standard and saved CRM View Settings records. Saved views merge these defaults and may retain old columns or kanban states.
  • When a lead custom field is intended to move to a deal, keep one matching deal field with the same label and field type. Ambiguous matches are not copied during conversion.
  • When default-view rules change, preserve the scope of default clearing. A user's new default must replace only that user's prior default for the same DocType.
  • When call-log links or lead creation from calls change, check call, lead, deal, task, and note permissions together. A call response must not expose a linked record that the current user cannot read.
  • When recording sources change, keep the direct-site path and external recording proxy contract aligned with telephony credentials and the client playback path.
  • When interaction timestamp sources change, update the live interaction writers and every email or WhatsApp backfill. Converted deals must inherit the relevant lead times without replacing newer deal activity.
  • When WhatsApp record names or fields change, update the legacy WhatsApp migration, its optional-app and old-table guards, state mappings, reference relinking, and the post-install path for sites that add WhatsApp later.
  • When all-day task behavior changes, keep the DocType field, quick-entry layout, due-date rules, reminder exclusion, morning digest, and user time-zone behavior aligned.
  • When invitation roles, account checks, or expiry rules change, check the inviter permission boundary, role inheritance, role-profile guard, Flow role grant, module access, password or login handoff, one-time acceptance state, and scheduled expiration together.
  • When notification fields or access rules change, check both dynamic reference targets and the query and record permission hooks. Reminder and reply notifications must keep the same recipient scope.
  • When dashboard widgets or scopes change, check role defaults, saved private layouts, manager-only filtering, Brief links, team member scope, and the fields shared by Lead and Deal filters.
  • When analytics fields or status meanings change, check the Insights workbook joins and measures. Reports depend on stable field names, status types, probabilities, exchange rates, and owner links.
  • When enrichment fields change on leads, check the layout, the organization-to-lead fill-empty copy, and lead-to-deal field mapping. User-entered values must remain protected.

Important failure modes

TriggerConsequenceGuard
A lead or deal status points to a name that is removed or renamed without a data patch.Existing records cannot resolve their required status and status-based views can fail or show incomplete data.Preserve linked names or add a migration that updates old records before removing the metadata.
Availability statuses or the User availability fields are added in only one install path.New sites and upgraded sites use different assignment and user-state behavior.Keep fresh-install seeding and the post-model migration aligned and add fields only when absent.
A layout names a field that the target DocType does not have.The field is omitted from the returned layout and the user may lose access to part of the intended form.Add the field and its layout change together. The layout reader filters unknown fields.
A saved layout contains field objects where the reader expects field names.Layout loading can fail before the form is built.Normalize legacy entries to fieldname or name before the layout is read.
A layout migration rewrites a site-customized layout as if it were the default.An administrator's field order or hidden-field choices are lost.Make patches idempotent and replace layouts only when their original default shape is still present.
Forecasting is enabled without its deal fields in the active layouts.The required values exist in validation but are hard to enter, which blocks deal saves.Update both Quick Entry and Side Panel layouts when enabling forecasting.
A field rule uses a property that a form surface does not honor.Users see inconsistent visibility or edit behavior between normal forms, quick entry, and child-table rows.Keep the field metadata contract aligned across layout sources and all field surfaces.
Standard dropdown items are removed from FCRM Settings.The application shell loses required navigation actions or later migration restores them unexpectedly.Keep standard rows protected and change the hook and sync behavior together.
An optional ERPNext custom-field patch runs without checking integration state.Migration can fail on a site that does not use ERPNext or can add irrelevant fields.Keep the integration gate and target-DocType checks in the patch.
Seen state is backfilled without the same enabled CRM-user scope as the product.Old leads and deals can appear unvisited to users or record users who should not be part of CRM history.Derive the backfill scope from the shared CRM role set and include only enabled users and Administrator.
A saved view keeps a stale default row or column after controller metadata changes.The view can hide new standard data or show a field that no longer exists.Review default-row and default-column sync when changing a DocType controller's list data.
Two custom lead fields match one deal field or differ in label or type.Lead data is not copied to the deal during conversion.Give the source and target custom fields a unique matching label and the same field type.
Default clearing is applied across users or DocTypes instead of its scoped owner and DocType.One user's view choice changes another user's default or changes an unrelated record type.Clear defaults only for the active user and the selected DocType.
A call response includes a linked lead, deal, task, or note without checking that record's read access.A user can see a related record outside their CRM scope.Apply permission checks to the call and to every linked record before returning the activity.
An external recording is treated as a site file, or a provider secret is missing.Playback can fail or expose an unsafe fetch path.Keep local file paths on direct playback and send external recordings through the recording access service with safe credential fallback.
An interaction backfill runs against a missing WhatsApp table or treats reactions as messages.Migration can fail or set incorrect reply state and dashboard counts.Check table availability and include only submitted non-reaction messages in the WhatsApp path.
A site adds WhatsApp after CRM installation but the legacy migration does not run again.Old accounts, templates, messages, and profile links remain in the former records and are not available through current CRM conversations.Keep the optional-app hook and the ordered migration entry aligned. Make the copy and profile-link steps safe to repeat.
Historical WhatsApp messages are inserted through normal outgoing-message behavior.Migration can send old messages to the provider again.Insert historical messages without triggering provider delivery, and preserve their original status and references.
An all-day task is handled like a timed task.Due status shifts across time zones or an unnecessary reminder is sent.Keep all-day storage, user-day comparisons, quick entry, and reminder rules on the same contract.
The Flow role patch adds roles to users managed by a Role Profile.A migration can conflict with role-profile control or leave users with unexpected access.Skip users with a role profile and add the role only when the Flow role exists.
A dashboard saves a widget or filter that its role or DocType does not support.The home page can fail to load or show data outside the intended scope.Validate widget names, role access, shared filter fields, positions, and user permissions before saving.
An Insights workbook query keeps an old status or field contract.Charts load with empty groups or report incorrect pipeline and forecast values.Update workbook joins and measures with the DocType and status metadata they consume.
An invitation accepts a non-pending record or leaves its key usable after acceptance.A stale or reused link can create or change a CRM user's access.Require Pending, clear the key on success, and expire pending records after three days.
An invitation bypasses the role-profile or inviter-role check.A user can receive CRM roles that conflict with managed access, or a sales manager can grant a higher role.Validate the existing user's role profile before insert and allow only the role levels permitted for the current inviter.
Invitation handling treats new and existing users the same way.A new user may not set a password, or an existing user may be accepted without the required sign-in step.Route new users to password setup and existing users to login before completing the public invitation flow.
Notification query rules and per-record rules use different access scopes.A notification can appear in a list but fail on open, or expose a message to the wrong user.Change the query and record permission hooks as one contract.
Enrichment fields are copied over values entered by a user or are missing from the active layout.Lead data is lost or the new context cannot be seen or used.Copy only into empty fields and update the related layout and conversion mapping together.

Key files

FileWhy to read it
crm/…/crm_lead.jsonShows the lead schema and its links to status, source, industry, territory, communication, SLA, product, and loss metadata.
crm/…/crm_deal.jsonShows the deal schema and the fields used by status probability, forecasting, currency, products, and ERPNext links.
crm/…/crm_lead.pyShows how status and loss metadata affect lead validation, how enrichment is copied, and how matching custom fields move into deals.
crm/…/crm_deal.pyShows how deal validation connects forecasting, currency, SLA, ownership, enrichment, and status history.
crm/…/crm_call_log.pyShows how call activity links to CRM records, resolves permitted related data, handles recordings, updates interactions, and creates leads.
crm/…/test_crm_call_log.pyStates the call-log contract for recording paths, related-record visibility, links, and lead creation.
crm/…/crm_task.jsonDefines task status, assignment, all-day behavior, due dates, and links to records.
crm/…/rules.pyExplains follow-up scope and the difference between timed and all-day due behavior.
crm/…/reminders.pyShows how timed follow-up reminders become CRM notifications.
crm/…/crm_invitation.pyShows the invitation-to-user flow, inviter and role-profile checks, role inheritance, Flow access, one-time acceptance, and expiry.
crm/…/test_crm_invitation.pyStates the invitation contract for acceptance, login and password handoff, role permissions, key protection, and expiration.
crm/…/crm_notification.jsonDefines notification types, read state, and dynamic references.
crm/…/crm_notification.pyShows notification access checks, duplicate handling, and realtime updates.
crm/install.pyCentral source for fresh-site defaults, availability metadata, custom fields, layouts, scripts, dropdown items, and restore behavior.
crm/…/fcrm_settings.jsonDefines site-wide settings, the navigation table, communication controls, calendar defaults, and morning digest.
crm/…/fcrm_settings.pyShows how settings alter layouts, required fields, currency behavior, standard navigation rows, and forecasting scripts.
crm/…/crm_fields_layout.pyExplains layout fallback, permission filtering, field shaping, and layout save behavior.
crm/…/crm_view_settings.pyShows how list, group-by, and kanban views merge DocType defaults and enforce ownership and default-view rules.
frontend/…/Field.vueShows how saved field metadata becomes user-facing controls and how dependent or script-driven field properties affect the form.
crm/…/crm_form_script.pyDefines active script lookup and the rules for editing standard scripts.
crm/…/home_layout.pyDefines role defaults, widget settings, private layouts, and validation for the CRM home page.
crm/…/brief.pyShows how personal and team work queues select records for the dashboard Brief.
crm/…/home_scope.pyDefines personal and sales-hierarchy team scope for dashboard data.
crm/…/recent_activity.pyShows how recent user actions become a permission-filtered activity list.
crm/…/sales_widgets.pyShows how sales value, forecast, funnel, and owner scope feed home cards.
crm/…/ask_flow.pyDefines the availability and approval rules for starting a Flow chat from CRM.
crm/…/crm.jsonDefines the standard CRM Insights queries, charts, filters, and dashboard layout.
crm/patches.txtShows migration order and the boundary between pre-model and post-model changes.
crm/…/add_all_day_to_task_quick_entry.pyShows how an existing task quick-entry layout receives the all-day field without replacement.
crm/…/backfill_interaction_timestamps.pyShows how email interaction times and waiting state are rebuilt for old records.
crm/…/backfill_whatsapp_interaction_timestamps.pyShows the optional WhatsApp backfill and its table and message guards.
crm/…/migrate_from_frappe_whatsapp.pyShows how old WhatsApp accounts, templates, messages, settings, and references move into the current records.
crm/…/link_existing_whatsapp_profiles_to_crm.pyShows how migrated WhatsApp profiles gain links to matching CRM entities without losing existing links.
crm/…/enable_morning_digest.pyShows how an old site receives the current morning digest default.
crm/…/give_sales_users_flow_role.pyShows how eligible existing sales users receive Flow access without overriding role profiles.
crm/…/add_availability_statuses.pyShows how existing sites receive default availability statuses and CRM availability fields on User.
crm/…/normalize_layout_field_entries.pyShows how old saved layout field objects are converted to field names.
crm/…/set_seen_for_existing_deals_and_leads.pyShows how migration sets a safe initial seen state for old leads and deals.
crm/…/session.pyDefines the CRM role set used to identify users included in CRM access and seen-state backfill.
crm/hooks.pyShows install, migrate, DocType view, route, permission, event, scheduled-task, and standard navigation registrations.
crm/…/install.pyShows how enrichment rules, field mappings, and settings defaults become editable CRM records.