Skip to content

fix(plugin-detail): a related tab's 「+ 添加」 no longer reads a row's own party as its catalog (#36659) - #36704

Merged
objectstack-fleet[bot] merged 2 commits into
mainfrom
claude/project-thread-bwxi1b
Nov 23, 2026
Merged

objectstack-fleet[bot] merged 2 commits into
mainfrom
claude/project-thread-bwxi1b

Conversation

@objectstack-fleet

@objectstack-fleet objectstack-fleet Bot commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Requested by Warren · project thread

Fixes #36659

Clause-②: no
Metadata-protocol: none

维护者速读

  • 在客户的「合同」页签点「添加」,不再弹出一张列着所有客户联系人的选择框,而是直接新建一份属于这个客户的合同;报价、订单、商机的产品明细页签照旧弹出产品选择框。
  • 属于记录详情页重做专题,修的是给相关子表页签加「添加」入口时,把合同上必填的「主要联系人」误当成了像产品那样的来源目录。
  • 出错的话只是某个页签的「添加」从选择框变成直接新建(或反过来),不碰已有数据,可直接撤回。
  • 无。

What changes

The related tab's 「+ 添加」 (objectstack#35601) derives its picker from the relationship when the page authors no add (derivedAddOf, ui/packages/plugin-detail/src/RelatedList.tsx). For a master_detail child it took the child's one other required single-valued lookup as the child's source catalog: the picker listed that lookup's object and a pick created a child row naming it. That is right for a line's product and wrong for a row's own party: crm_contract is master_detail to crm_account and requires crm_contact (its primary contact, dependsOn: ['crm_account']). So an account's 合同 tab opened a picker of crm_contact with no filter (the reported GET /api/v1/data/crm_contact?populate=crm_account&top=10&skip=0), listing other accounts' contacts, and a pick would have tried to create a contract from a contact.

The function's own docblock already stated the condition for a catalog: "the field every row must name, so a pick is a whole row". This PR checks both halves of that sentence before returning a catalog picker:

  • The candidates do not depend on the row. A required lookup with a dependsOn entry, or a lookupFilters comparand { $record }, is scoped by the row; the picker lists the catalog for the whole list and cannot apply that scope. Such a lookup is a party of the row, not a catalog (scopedByRow).
  • The pick leaves nothing for a person to write. Every other required field of the child must be filled by the insert: a non-null defaultValue or a select option marked default (the engine's applyFieldDefaults, packages/objectql/src/engine-select-option-default.test.ts), readonly, or a computed type (isComputedFieldType: formula, summary, rollup, autonumber). required is the writer's contract, so a contract that still needs its value and dates is filled in on its form, not completed by a pick (insertDefaults).

When either fails, derivedAddOf returns undefined, which is the existing "master_detail with no catalog" path: 「+ 添加」 opens New with the parent filled in. The lookup path (pick unlinked children of the list's own object) and an authored add are untouched.

Measured against HotCRM 6.6.0 metadata (read, not run): crm_contract loses the picker on both counts (contact dependsOn the account; contract_term_months, start_date, end_date, contract_value required with no default). crm_opportunity_line_item, crm_quote_line_item keep the product picker (product required, no dependsOn, quantity required with defaultValue: 1, unit_price deliberately not required).

Changeset: @object-ui/plugin-detail patch.

Tests

ui/packages/plugin-detail/src/__tests__/RelatedList.enlargedToolbar-27524.test.tsx, in the existing describe "「+ 添加」 is decided by the relationship":

  • a contract-shaped child (master_detail parent, required contact dependsOn the parent, required value and start date, autonumber number): 「+ 添加」 calls New, opens no picker, and no read of contact is made;
  • derivedAddOf returns undefined for a required lookup scoped by dependsOn, and for one whose lookupFilters reads $record;
  • derivedAddOf returns undefined when another required field has no default;
  • control: a line whose other required fields default (defaultValue, select option default), are readonly or computed, and whose product carries a static lookupFilters, keeps { picker: { object: 'product' }, linkField: 'product' }. The existing catalog test ("master_detail with a catalog: the picker lists the catalog…") passes unchanged.

Reverse verification: with the fix committed, RelatedList.tsx restored from origin/main and the file run, then restored from HEAD (git diff HEAD empty): the 4 new defect tests fail, the control and the 17 existing tests pass.

Package run under the verify lock
pnpm --dir ui exec vitest run --maxWorkers=2 packages/plugin-detail/
 Test Files  415 passed | 1 skipped (416)
      Tests  3898 passed | 18 skipped (3916)
os-verify-lock: VERDICT command-exit 0

pnpm --filter @object-ui/plugin-detail type-check   (at 26c5daf1)
> tsc --noEmit && tsc -p tsconfig.test.json
os-verify-lock: VERDICT command-exit 0

The package run started before the select-option-default arm was added; the touched test file was re-run at 26c5daf1: Tests 21 passed (21).

Acceptance notes

  • Not changed here, noted: the derived catalog picker does not carry the catalog lookup's own static lookupFilters (for example HotCRM's crm_product lookup is_active = true on opportunity lines), so it can offer a retired product. Read from code, not reproduced in a browser.
  • Not changed here, noted: the reported empty, English 「NAME」 column follows from the wrong object (contacts have no name); with the contract tab no longer opening a picker it does not appear there.
  • Found while verifying, not changed here (same tab, the lookup arm this PR does not touch): on an opportunity's 合同 tab, 「+ 添加」 lists unlinked contracts of every account (HotCRM 6.6.0, opportunity "Initech Cloud Migration": the picker offers CTR-0004 of Stark Medical next to CTR-0003 of Initech Solutions; request GET /api/v1/data/crm_contract?populate=crm_account&top=10&skip=0&filter=[["crm_opportunity","is_empty"]]), although crm_contract.crm_opportunity declares dependsOn: ['crm_account']. The same picker's first column is headed 「NAME」 and is empty, because the derived picker's label field falls back to name and a contract's name field is contract_number. Reported to the seat for filing.
  • The HotCRM-side card 客户 → 合同页签出现「添加(关联已有)」,弹窗列出的是全部联系人:合同等主从子对象应只能新建 hotcrm#2747 (declare that master-detail children offer no "link existing") is not needed for the contract tab after this change; whether it is still wanted is that card's call.

Verification

Read first:

  1. ui/packages/plugin-detail/src/RelatedList.tsx, derivedAddOf: the two new early returns (riskiest hunk: leftToWrite, which decides which existing line tabs keep their picker).
  2. scopedByRow and insertDefaults just below it.

Browser, HotCRM 6.6.0 (d513851, objectstack dev --seed-admin --fresh) behind this branch's Console (Vite, DEV_PROXY_TARGET), zh-CN, at 961e6e57:

  • Account "Acme Corporation" → 合同 tab → 「+ 添加」: the 新建合同 form opens with 所属客户 = Acme Corporation filled in and 主要联系人 empty; no picker dialog ([data-testid="record-picker-dialog"] count 0); the requests after the click are the record page's own reads, no GET /api/v1/data/crm_contact.
  • The served schema carries what the rule reads: GET /api/v1/meta/objects/crm_contract → crm_contact required: true, dependsOn: ["crm_account"]; contract_value, start_date required: true with no default.
  • Before (origin/main, the card's own repro on 18.6.0): the same click opened 「添加」 listing contacts of two accounts.

Screenshots are attached in the project thread (GitHub's image store takes browser uploads only): the account's 合同 tab; the New contract form after 「+ 添加」.

Two-minute check: on a HotCRM account, open the 合同 tab and click 「+ 添加」: the New contract form opens with the account filled in, no picker. On an opportunity's product lines tab, 「+ 添加」 still opens the product picker.


Generated by Claude Code

…ick makes a whole row

A master_detail child's one other required lookup was taken as its source
catalog even when it was a party of the row (a contract's primary contact,
scoped by dependsOn to the account) and when the child still had required
fields a pick leaves empty. The account's contracts tab then offered a picker
of every account's contacts. The catalog now needs candidates that do not
depend on the row and no other required field left for a person to write.

Claude-Session: https://claude.ai/code/session_01JQwxbY1aynwSYJFZFRNKBL
@github-actions github-actions Bot added size/m documentation Improvements or additions to documentation tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface labels Nov 23, 2026
@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#1 · os-warren · session_01JQwxbZeHNsF3RWcWpj7rGj

维护者速读

在客户的「合同」页签点「添加」,以前会弹出一个列着所有客户联系人的选择框(选了还会出错)。现在直接新建一份属于这个客户的合同,客户已经填好。报价、商机的产品明细页签仍然弹出产品选择框。浏览器里在 HotCRM 上验证过。
同一个页签上另一处问题(商机的合同页签列出别的客户的合同、首列空白)已另立卡 #36707。
要你做的:无。

席位核对 — ACCEPT (L1) · repo:objectstack#1 · head 961e6e57 · 2026-11-23T13:08Z

  • Shape: Fixes #36659. ui/packages/plugin-detail/src/RelatedList.tsx (derivedAddOf gains two early returns, scopedByRow and insertDefaults), its test file, and a @object-ui/plugin-detail patch changeset. Clause-②: no. Metadata-protocol: none. Not governed; +129/−2.
  • Read: a required lookup counts as the child's catalog only when a pick makes a whole row: its candidates do not depend on the row (no dependsOn, no lookupFilters comparand reading $record), and every other required field is filled without a person (non-null defaultValue, a select option default, readonly, or a computed type). Otherwise the existing no-catalog path runs and 「+ 添加」 opens New with the parent filled. The lookup arm and an authored add are untouched. The fallback is the conservative direction: a mis-read loses a picker, never creates a wrong row.
  • Evidence (thread): 4 new defect tests red without the fix, green with it; control keeps the product picker for quote and opportunity lines. plugin-detail 3898 passed; type-check green. Live on HotCRM 6.6.0 behind this branch's console: the account's 合同 tab opens 新建合同 with 所属客户 filled and makes no crm_contact read.
  • Out of scope, filed: 记录页相关页签「添加」关联已有记录时不按客户过滤,且首列「NAME」为空(商机 → 合同) #36707 (the lookup arm ignores the child's dependsOn; empty 「NAME」 column).
  • Gates: 59 check-runs on 961e6e57: 44 success, 15 skipped, 0 failed. K = 4 behind main (< 15).
  • Landing: ready + auto-merge now. On merge, 记录页相关列表的「添加」弹窗查错了对象:客户 → 合同页签点「添加」,列出的是全部联系人(18.6.0) #36659 closes and the seat clears its label.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation size/m tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface

Projects

None yet

Development

Successfully merging this pull request may close these issues.

记录页相关列表的「添加」弹窗查错了对象:客户 → 合同页签点「添加」,列出的是全部联系人(18.6.0)

2 participants