Repository navigation
feat(sales): contracts have a Contract Name, their record title (#2746) - #2787
Merged
Merged
Conversation
The contract's title was its autonumber, so approvals, notices, lookup chips and the account's Contracts tab showed only CTR- numbers. A required name field is now the nameField; drafted contracts take the source's name, and a report-first script names existing contracts. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01J8VVAmQQaqVXpJepCqm4Xa
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01J8VVAmQQaqVXpJepCqm4Xa
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01J8VVAmQQaqVXpJepCqm4Xa
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01J8VVAmQQaqVXpJepCqm4Xa
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
Contributor
Author
|
repo:hotcrm#1 · huangyiirene · session_01J8VVAmQQaqVXpJepCqm4Xa Seat record · ACCEPT · head
席位核对
|
This was referenced Nov 25, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Requested by Irene · project thread
Fixes #2746
Clause-②: no
Metadata-protocol: none
Metadata-impact: maintainer — a new required field on an existing object (
crm_contract.name, the new record title; rows saved before it hold no name until the backfill script runs) and changed seed data (the four demo contracts, en and zh-CN, gain names)维护者速读
What changes
crm_contract.name, "Contract Name" —Field.text,required: true, searchable, 255 chars, groupbasic; it is thenameField.searchableFields: ['name', 'contract_number'].contract_numberstays first inhighlightFields, so the record header's strip and the platform lookup picker show the number beside the name (the picker draws the strip's first field under each candidate and as its second column — read in the 18.6.0 console bundle, then seen in the browser, screenshots below). No formula title: the platform's own picker columns carry the number.storage.notNull, on purpose (AGENTS.md rule 11: comment at the field, pinned intest/contract-name.test.ts). Measured on 18.6.0: booting the new field withstorage: { notNull: true }against a database created before it fails the contract's whole schema sync —alter table crm_contract add column name text not null - Cannot add a NOT NULL column with default value NULL— and leaves contracts unwritable.requiredalone is the spec's sanctioned posture for this ("required alone is the criteria_json posture (legacy null rows rest)",FieldSchema.storage): every new write needs a name, and old rows still save edits that leave the name alone (measured, and pinned).relatedListColumns); the printed contract's parties block._contract-draft.tsgainsContractDraftSource.name): Draft Contract on an order takes the order's name (an order created from a quote already carries the quote's name); the switched-offquote_accepted_contract_draftflow takes the quote's name, else its opportunity's (newget_opportunitynode), else the quote number — the ruling's "报价名称(没有则带商机名称)".crm.contract_drafted,crm.contract_expired,crm.contract_renewalread one composed{{contract}}(CTR-0006 · Annual Service 2027, the number alone for an unnamed row) built by_contract-label.ts, in all four template packs — one value because a notice missing a value is not sent (notification templates: declare required variables or write literal defaults, so a flow that omits a new variable no longer mails a blank (platform ruling on objectstack#32678) #2451).scripts/backfill-contract-names.ts(report-only without--apply, rerunnable, writes onlynameon unnamed rows): the source quote's name (the quote of an order naming the contract, else the single accepted quote of its opportunity), otherwise "account name + start date".docs/MAINTENANCE.md§3.6 and the changeset tell admins to run it.description, so an upgraded demo database is not seeded twice).crm_sales_contractsandcrm_sales_orders(en + zh); invoice import mapping comment;docs/feature-inventory.mdCON-001;docs/STATUS.mdfield count.Tests
test/contract-name.test.ts: title, required, no column constraint, number first in the strip, list/form/print order, four pack labels, every demo contract named; on the booted stack: a nameless insert refused (VALIDATION_FAILEDonnameat the engine,400over REST), clearing a name refused, an unnamed legacy row still saves an unrelated edit, search by name and by number, the invoice import resolves the Contract column by number and by name, the switched-on quote flow names the contract by the quote, and by the opportunity when the quote has none.test/backfill-contract-names.test.ts: the script run with--applyagainst a stubbed door: the PATCH bodies for each rule, named rows untouched.sales-order-draft-contract.test.ts: Draft Contract's contract is named as the order (= the quote).contract-drafted-notice/flow-scheduled: notices carryCTR-… · name.o2c-order-contract-later: an invoice's history names the contract by its title. 25 suites' contract fixtures gain a name.with the opportunity's name when the quote has nonered (Expected: "Named deal 7" / Received: "ABLATED", 1 failed / 15 passed); restore proven bygit diff HEADempty and the file's hash equal to the HEAD blob.pnpm verify, and the rerun after merging main
pnpm verifyon26714976(validate, typecheck, lint, source hygiene, build, full test run) under the shared lock:Then
origin/main(d9875549, #2785, which reads the quote flow this PR edits) was merged; on the merge heade99d0135:tsc --noEmitclean, andtest/quote-accept-copy.test.ts,test/contract-name.test.ts,test/sales-order-draft-contract.test.ts3 files / 44 tests passed, VERDICT command-exit 0.Acceptance notes
scripts/backfill-contract-names.ts --applyruns, an old contract's header, lookup chips and approvals fall back to the record id, and its notices name it by number. Measured on a dev database created onmainand booted on this branch: 4 of 4 contracts unnamed, schema sync clean, no duplicate demo rows; report then--applynamed 4/4 (CTR-0001from its order's quote, the other three by account + start date, an activated and an expired contract among them); a second run reported 0.contract CTR-…(their text is matched by the renewal sweep's legacy-title check,_legacy-task-titles.ts); the invoice/payment refusals that name a contract still name it by number. Neither was in the card's list.storage.notNullfield to an existing table asNOT NULLwith no default, so on SQLite the whole object's sync fails even with zero rows, instead of adding the column nullable and reportingtighten_not_nulldrift as the spec's describe ("a destructive migration gated by the schema-drift ceremony (backfill first)") promises. Once the platform does that, a later PR can declarestorage.notNullafter the backfill.Read first
src/sales/objects/contract.object.ts— the field, the title, why nostorage.notNull.src/revenue/flows/quote-accepted-contract-draft.flow.ts— the name fallback chain and the newget_opportunitynode.scripts/backfill-contract-names.ts— the naming rule for existing rows.Two-minute check
pnpm dev, open Contracts: the first column is Contract Name, the second Contract Number; New asks for Contract Name first; on a new Billing Milestone, the Contract picker shows each name withContract Number: CTR-…under it.Verification
Browser, dev boot on this branch (en-US and zh-CN, desktop 1440×900; not on a phone): All Contracts list, contract record header, account Contracts tab, the new-contract form, the billing-milestone contract picker, and Draft Contract on an order (the drafted CTR-0005 is named
Globex Seat Expansion Order; its inbox notice'stemplateData.contractisCTR-0005 · Globex Seat Expansion Order). Before/after-backfill screenshots are in the project foldercontract-name-2746/(not committed). The chain walked: order → Draft Contract → contract → billing milestone picker.🤖 Generated with Claude Code
https://claude.ai/code/session_01J8VVAmQQaqVXpJepCqm4Xa