Lead and deal lifecycle
Leads and deals are the CRM’s two main sales records. A lead captures an early customer opportunity. A deal tracks a qualified sales opportunity with an owner, contacts, value, forecast, and outcome. Together they move customer work from first contact to a won or lost result, while keeping the related people, organizations, and work history connected. See also CRM record management, contacts and organizations, record productivity workflows, and client record views.
Sales record model
Leads and deals share a common record shape for identity, ownership, status, customer details, products, response service levels, interaction state, and work history. A lead is the starting record. A deal is the sales record that can be created from that lead or created on its own.
Lead records
The CRM Lead record represents a person or an organization that may become a customer. It stores the lead’s name and contact details, organization information, source, owner, products, conversion flag, and response measures. It also has a numeric lead score and a Cold, Warm, or Hot temperature for prioritization.
Lead ownership also drives access and assignment. The record can retain a status change log, notes about a lost lead, and service-level response data. The converted flag marks that the lead has produced a deal. Converted leads are not shown in the main lead list. Lead fields marked as unique are checked when the record is saved, so duplicate values are rejected even when the database index does not enforce the rule.
References: crm/…/crm_lead.py• L91-105 crm/…/crm_lead.py• L155-183 crm/…/crm_lead.py• L465-534 frontend/…/Lead.vue• L344-356
Deal records
The CRM Deal record represents a qualified sales opportunity. It links to an organization and can link back to the lead that started it. It can also hold several contacts, with one primary contact supplying the deal’s main communication values.
Deals add sales planning data to the shared record model. This includes the next step, owner, status, probability, expected and actual value, expected closure date, closed date, currency, and products. The status configuration supplies a default probability when needed. A deal that reaches a Won status receives a closed date. The record also keeps the latest inbound and outbound interaction times and the point at which it began waiting for a reply.
References: crm/…/crm_deal.py• L81-107 crm/…/crm_deal.py• L122-165 crm/…/crm_deal.py• L247-301 crm/…/crm_deal.json• L486-513
Status progression
Status names are business-configurable labels. Each lead or deal status also has a type that gives the label a shared meaning: Open, Ongoing, On Hold, Won, or Lost. Position controls the order in which statuses appear. Color helps users read the same state in lists, boards, and detail views.
Lead statuses
New leads use New when that status exists. Otherwise, the system uses the first status whose type is Open. Users can change the status from the lead detail header or from a view grouped by status. Each change is recorded in the lead’s status change log.
A lost lead must have a lost reason. If the reason is Other, the user must also enter lost notes. This makes the end of the lead path useful for later sales review instead of treating every lost result as an unexplained stop.
References: crm/…/crm_lead.py• L114-119 crm/…/crm_lead.py• L157-167 crm/…/crm_lead_status.json• L25-46 frontend/…/Lead.vue• L27-48
Deal statuses
New deals use Qualification when that status exists. Otherwise, the system uses the first status whose type is Open. Deal status configuration also carries a probability, which supports a shared view of pipeline confidence.
When forecasting is enabled, a deal needs an expected value and an expected closure date. A won status sets the closed date. A lost deal follows the same reason rule as a lead: it needs a lost reason, and Other needs an explanation.
References: crm/…/crm_deal.py• L120-125 crm/…/crm_deal.py• L270-290 crm/…/crm_deal_status.json• L26-51 frontend/…/Deal.vue• L31-43
Status controls
The client loads lead and deal statuses in position order. It uses the status type and color to build status menus, markers, and groups. Custom record actions can add or limit the statuses shown for a record, but the selected value must still follow the record’s status rules.
References: frontend/…/statuses.js• L15-45 frontend/…/statuses.js• L82-112 frontend/…/Lead.vue• L412-417 frontend/…/Deal.vue• L557-562
Lead conversion
Lead conversion moves an early opportunity into the deal path without losing its source record. The conversion can reuse an existing contact and organization or create them from the lead details. It then creates a deal linked to the lead and carries across compatible sales data.
This diagram shows the conversion path from a lead to the connected customer records and deal.
flowchart LR
L[Lead] --> V{Existing deal?}
V -->|No| S{Lead status lost?}
S -->|No| R{Reuse or create records}
R --> CT[Contact]
R --> ORG[Organization]
CT --> D[Deal linked to lead]
ORG --> D
L -->|compatible details| D
D --> C[Mark lead converted]
The conversion form lets the user choose an existing organization and contact. If the user does not choose existing records, the system creates an organization from organization details and a contact from person details when those details are present. The new deal keeps the lead link and transfers matching fields, including the lead owner to the deal owner. It does not copy fields that belong only to the lead, such as the lead status and conversion state.
Conversion rejects a lead whose current status has type Lost. A conversion request can also state how to handle a lead that already has a deal: the normal interactive choice can create another deal, while an automation can return the existing deal or fail. The lead is locked while this state is checked, so concurrent conversion requests do not make the same decision from stale state. A successful conversion marks the lead converted and emits a lead-converted event for downstream CRM work.
After conversion, the client opens the new deal. The lead remains available for history and reporting, but the normal lead list filters it out through converted = 0.
References: crm/…/crm_lead.py• L354-436 crm/…/crm_lead.py• L462-463 crm/…/crm_lead.py• L545-631 frontend/…/Lead.vue• L39-51 frontend/…/Lead.vue• L433-451
List and detail views
The list and detail views serve different parts of the sales workflow. Lists help users scan and sort a working set. Detail views provide full customer context and the controls that change a record.
List views
Both leads and deals support list, grouped, and kanban views. The list can load more records, resize columns, filter from cell values, select records for bulk actions, and open a record while retaining the current view in the breadcrumb path. Kanban and grouped views use the configured status field when the user organizes work by status.
Both pages provide a create action. In a kanban view, creating a record from a status column carries that column’s status into the new record. This lets the board serve as a starting point as well as a review surface. Custom list actions can extend the list header actions.
Lead rows emphasize the person, organization, status, email, mobile number, assignment, and last change. Deal rows emphasize the organization, annual revenue, status, email, mobile number, assignment, and last change. Both views can show response service-level state and counts for emails, notes, tasks, and comments.
Opening a lead or deal marks it as seen by the current user. The list uses that per-user state to dim visited rows, which helps the user distinguish new work from records already reviewed. This state is available in list and grouped views when the record tracks seen users.
The lead list excludes converted leads. The deal list has no matching conversion filter because deals are the destination records for converted sales work.
References: frontend/…/Leads.vue• L4-29 frontend/…/Leads.vue• L31-44 frontend/…/Leads.vue• L235-256 frontend/…/Leads.vue• L522-530 frontend/…/Deals.vue• L4-29 frontend/…/Deals.vue• L30-43 frontend/…/Deals.vue• L209-230 frontend/…/Deals.vue• L488-496 frontend/…/LeadsListView.vue• L42-46 frontend/…/DealsListView.vue• L42-46 frontend/…/ListRows.vue• L23-46 frontend/…/useVisitedRecords.ts• L4-18 frontend/…/Lead.vue• L340-345 frontend/…/Deal.vue• L509-517 crm/…/doc.py• L354-369 crm/…/crm_lead.json• L519-524 crm/…/crm_deal.json• L569-574
Detail views
Each detail view combines a status control, assignment control, record data, and a work timeline. The lead detail adds conversion. The deal detail adds organization and contact management, including links to the related records and a primary-contact marker.
Both details expose activity, email, comments, data, events, calls, tasks, notes, and attachments. WhatsApp appears when that feature is enabled. The deal can also show quotations when the user has access. Users can send email when a visible tab supports the composer, make a call when a usable number exists, visit the website, attach files, enrich the record from its website, and delete the record when permitted.
The deal detail also lets the user create a follow-up and shows the next open follow-up task. Its follow-up label uses the organization first, then the primary contact, then the deal title, so the action stays tied to the best available customer context.
The visible tabs can include record-specific additions. Email actions first find a visible tab that supports the composer. If no such tab exists, the email action is disabled instead of opening a hidden or unavailable surface.
References: frontend/…/Lead.vue• L39-51 frontend/…/Lead.vue• L54-72 frontend/…/Deal.vue• L41-61 frontend/…/Deal.vue• L123-145 frontend/…/Deal.vue• L563-622 frontend/…/Deal.vue• L779-845 frontend/…/Deal.vue• L1001-1015
Conversion-oriented CRM work
Leads and deals are work hubs, not only status rows. Their owners and assignees give work to a sales user. Their status, forecast, response measures, and linked customer records give the team a shared view of progress and next action.
Ownership and assignment
Creating a lead or deal defaults the owner to the current user in the quick-entry form. Saving an owner shares the record with that user and assigns the record for follow-up. During lead conversion, the new deal keeps the lead owner even when co-assignees are copied. This keeps ownership distinct from the people who also receive follow-up work.
References: frontend/…/LeadModal.vue• L239-249 frontend/…/DealModal.vue• L290-300 crm/…/crm_lead.py• L94-107 crm/…/crm_deal.py• L93-111
Customer context
An organization gives a lead or deal company context. Contacts give a deal the people involved in the opportunity. Enrichment can add company information from a website, while the existing organization and contact links prevent a conversion from creating duplicate customer records when the user already has them.
The deal detail keeps contact membership and primary-contact choice visible beside the deal. Its primary contact supplies the main phone and email values used by deal actions. The contact service returns the primary contact first, so the detail view can present the main person before other linked contacts.
References: crm/…/crm_lead.py• L217-306 crm/…/crm_deal.py• L140-162 crm/…/api.py• L4-29 crm/…/test_crm_deal.py• L266-283 frontend/…/Deal.vue• L154-290
Work signals
Status history, forecast values, expected closure dates, response service levels, interaction times, and reply-wait state give sales users signals for what needs attention. Notes and tasks can be created from a list row and are linked to the selected lead or deal. The detail timeline then gives the fuller work history. See record productivity workflows for the shared activity surfaces.
References: frontend/…/Leads.vue• L201-231 frontend/…/Deals.vue• L175-205 frontend/…/Leads.vue• L557-595 frontend/…/Deals.vue• L523-560 crm/…/crm_lead.json• L229-242 crm/…/crm_lead.json• L427-454 crm/…/crm_deal.json• L486-513
Change checklist
When these files or sections are changed, remember to consider these:
- Status type, position, color, or probability changes affect status menus, status groups, kanban columns, and deal forecast defaults.
- Lead or deal field changes affect both the conversion field map and the conversion form’s prefill rules. Matching custom fields depend on both label and field type.
- Conversion changes must preserve the lead-to-deal link, the already-converted retry policy, the conversion event, and the
convertedlist filter. Otherwise, repeated automation can create the wrong result or active lists can show completed lead work. - Lost-lead rules must stay aligned with conversion retries. A retry that returns an existing deal must not be blocked by a later lost status, while a new deal must still reject a lost lead.
- Contact primary-state changes affect the deal’s summary phone and email values, the contact order returned to the detail view, and the call action.
- Forecast setting or currency changes affect deal validation, expected value behavior, exchange rates, and the fields shown in create and conversion forms.
- Lead score and temperature changes affect the priority signals shown in lead records and any list or work surface that consumes them.
- Changes to list metadata must stay aligned with both list pages and both list row components so list, grouped, and kanban views display the same sales signals.
- Changes to list creation or kanban column defaults must keep the column field aligned with the create form defaults. Otherwise, a record created from a status column can lose the status shown to the user.
- Changes to seen-state tracking must keep record metadata, list data, detail-page marking, and row styling aligned for both leads and deals.
- Changes to visible detail tabs must stay aligned with email actions. A tab that hides the composer must also disable or redirect the email action.
- Changes to conversion assignment must keep the lead owner separate from copied co-assignees. Otherwise, the newest assignment can silently replace sales ownership.
- Changes to fields marked unique must preserve save-time duplicate checks for customized lead fields.
- Changes to interaction timestamps or reply-wait state must keep the record fields and the activity signals that use them aligned for both leads and deals.
- Changes to deal follow-up actions must keep the next-task display and its customer label aligned with the deal’s organization and primary-contact context.
Important failure modes
| Trigger | Consequence | Guard |
|---|---|---|
| A lead or deal enters a lost status without a reason | The record cannot be saved. Other also requires notes. | The detail flow opens the lost-reason prompt, and server validation enforces the rule. |
| A new conversion runs for a lead with a lost status | No deal is created. | Move the lead out of the lost state before starting a new conversion. |
An already-converted lead is retried with Return Existing or Fail | Return Existing gives the original deal. Fail stops with an error. | Choose the retry policy that matches the caller’s need. |
| Two conversion requests use stale lead state at the same time | They can make conflicting decisions about the same lead and deal. | The conversion flow locks the lead before it checks for an existing deal. |
| Forecasting is enabled without expected deal value or expected closure date | The deal cannot be saved. | Complete both forecast fields before changing or saving the deal. |
| More than one deal contact is marked primary | The deal cannot save its primary contact data. | Keep one primary contact. |
| A deal has no primary contact or its primary contact has no mobile number | The deal call action cannot place a call. | Add a contact and set one contact with a usable mobile number as primary. |
| Conversion requests an existing contact or organization without selecting one | Conversion stops before creating the deal. | Either select the existing record or turn off the existing-record choice. |
| A lead has already been converted | It is hidden from the active lead list even though its source record remains available. | Open the linked deal or find the lead through a broader record search. |
| A kanban create action does not pass the selected column status to the create form | The new record starts in a different status from the column where the user created it. | Keep the kanban column and create-form status mapping aligned. |
| Seen-state metadata or list data is missing for a tracked record | The user cannot see which lead or deal they already reviewed. | Keep track_seen, _seen list data, detail-page marking, and row display in sync. |
| No visible detail tab supports email composition | The email action is disabled. | Keep at least one eligible email tab visible when email is enabled for the record. |
| Lead conversion copies co-assignees after setting the owner | The newest assignment can become the deal owner. | Restore the lead owner after co-assignee creation. |
| A customized unique lead field repeats a value | The lead save is rejected. | Keep the save-time unique-field check active for customized fields. |
Key files
| File | Why to read it |
|---|---|
| crm/…/crm_lead.py | Shows lead validation, assignment, customer-record creation, conversion behavior, retry policy, unique-field checks, and list metadata. |
| crm/…/crm_deal.py | Shows deal validation, forecast behavior, primary-contact rules, contact actions, and direct deal creation. |
| crm/…/api.py | Provides the deal contact view with the primary contact first. |
| frontend/…/Lead.vue | Shows lead detail actions, status changes, conversion entry, visible work tabs, email behavior, and seen-state marking. |
| frontend/…/Deal.vue | Shows deal detail actions, status changes, contacts, organization context, follow-up actions, visible work tabs, email behavior, and seen-state marking. |
| frontend/…/ConvertToDealModal.vue | Shows user choices and required fields in lead conversion. |
| frontend/…/Leads.vue | Shows the active lead list, supported views, conversion filter, kanban creation defaults, and row-level work actions. |
| frontend/…/Deals.vue | Shows the deal list, supported views, kanban creation defaults, and row-level work actions. |
| crm/…/crm_lead_status.json | Defines the shared meaning and display order of lead statuses. |
| crm/…/crm_deal_status.json | Defines deal status meaning, display order, and probability. |
| frontend/…/ListRows.vue | Connects per-user seen state to list and grouped row display. |
| frontend/…/useVisitedRecords.ts | Defines how detail views mark records seen and how lists read that state. |
| crm/…/doc.py | Adds seen-state data to supported list responses and records a user’s visit. |