openerp-discovery

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

openerp-discovery — 发现任意业务对象的查询方式

openerp-discovery — Discover Query Methods for Any Business Object

先读
../openerp-shared/SKILL.md
(鉴权、退出码、输出契约)。
金蝶业务对象上千个。发现层让你在运行期查到任意对象,无需等领域命令封装。高频对象已有领域命令(见
../openerp-domains/SKILL.md
),其余一律走这套三步发现。
First read
../openerp-shared/SKILL.md
(Authentication, Exit Codes, Output Contracts).
Kingdee has thousands of business objects. The Discovery Layer allows you to query any object at runtime without waiting for domain command encapsulation. Domain commands are already available for high-frequency objects (see
../openerp-domains/SKILL.md
), while all other objects follow this three-step discovery process.

三步发现工作流

Three-Step Discovery Workflow

bash
undefined
bash
undefined

1) 找对象 FormId(搜 BOS_ObjectType)

1) Find the object's FormId (search BOS_ObjectType)

openerp objects --keyword 销售订单
openerp objects --keyword Sales Order

→ 行含 [FID, FName, FSubSystemId],FID 即 FormId(如 SAL_SaleOrder)

→ Rows contain [FID, FName, FSubSystemId], where FID is the FormId (e.g., SAL_SaleOrder)

2) 查该对象的可用字段

2) Query available fields of the object

openerp schema SAL_SaleOrder --fields-only
openerp schema SAL_SaleOrder --fields-only

→ 各 entry 的字段 key/中文名/类型/关联对象(lookUpForm)

→ Each entry includes field key/Chinese name/type/related object(lookUpForm)

3) 用发现到的字段查数据

3) Retrieve data using the discovered fields

openerp query --form-id SAL_SaleOrder
--fields "FBillNo,FDate,FCustId.FName,FMaterialId.FNumber,FQty"
--filter "FBillNo='XSDD000006'" --top 20

> **发现前先回忆、发现后即沉淀**:三步发现前先 `ls ~/.config/openerp/object-notes/` 看该 FormId 有无既往经验;查通后把已验证的字段/过滤/陷阱写回 `object-notes/{FormId}.{profile}.md`。约定见 [`../openerp-shared/SKILL.md`](../openerp-shared/SKILL.md) §6「对象经验」。
openerp query --form-id SAL_SaleOrder
--fields "FBillNo,FDate,FCustId.FName,FMaterialId.FNumber,FQty"
--filter "FBillNo='XSDD000006'" --top 20

> **Recall before discovery, document after discovery**: Before starting the three-step discovery, run `ls ~/.config/openerp/object-notes/` to check if there is any existing experience for the FormId; after successfully querying, write the verified fields/filters/pitfalls back to `object-notes/{FormId}.{profile}.md`. For conventions, see §6 "Object Experience" in [`../openerp-shared/SKILL.md`](../openerp-shared/SKILL.md).

关键规则(实测坐实,务必遵守)

Key Rules (Verified through Practice, Must Follow)

  • 字段 key 不要带 entry/分录前缀。 ExecuteBillQuery 把表头与分录字段拉平在同一命名空间:用分录字段就直接写它的 key(如
    FMaterialId
    FQty
    ),不要
    FEntity.FMaterialId
    /
    FSaleOrderEntry.FQty
    (会报“标识为 FEntity 的字段不存在”)。
  • 关联字段用点号下钻
    FSupplierId.FName
    FMaterialId.FNumber
    FCustId.FNumber
    schema
    输出里字段的
    lookUpForm
    非空即表示它是关联字段,可点号取关联对象的字段。
  • 字段名大小写敏感,以
    schema
    实测为准(同一概念在不同单据可能是
    FMaterialId
    /
    FMATERIALID
    /
    FMaterialID
    )。
  • 查询要带过滤或 --top,避免全表扫描;超过 2000 行用
    --page-all
  • 某字段整列为
    null
    :多为无数据权限或字段名拼错 → 回到
    schema
    核对。
  • Do not add entry/sub-entry prefixes to field keys. ExecuteBillQuery flattens header and sub-entry fields into the same namespace: directly use the key for sub-entry fields (e.g.,
    FMaterialId
    ,
    FQty
    ), do not write
    FEntity.FMaterialId
    /
    FSaleOrderEntry.FQty
    (this will trigger an error "Field identified as FEntity does not exist").
  • Drill down related fields with dots:
    FSupplierId.FName
    ,
    FMaterialId.FNumber
    ,
    FCustId.FNumber
    . If the
    lookUpForm
    of a field in the schema output is non-empty, it means it is a related field, and you can use dots to retrieve fields of the related object.
  • Field names are case-sensitive, take the actual schema output as the standard (the same concept may be
    FMaterialId
    /
    FMATERIALID
    /
    FMaterialID
    in different documents).
  • Queries must include filters or --top to avoid full table scans; use
    --page-all
    for results exceeding 2000 rows.
  • If an entire column of a field is
    null
    : this is mostly due to lack of data permissions or incorrect field spelling → go back to
    schema
    to verify.

命名陷阱与不支持项

Naming Pitfalls and Unsupported Items

  • 即时库存现量用
    STK_Inventory
    (现存量余额对象),不是
    STK_InventoryQuery
    (后者是查询界面,无字段模型)。已封装为
    openerp inventory balance list
  • 报表/账表(模型类型 900、GUID 命名,如“销售订单执行明细表/销售明细表”):仍不支持,需
    GetSysReportData
    ;或改用对应单据(如
    SAL_OUTSTOCK
    出库明细)复现。
  • 个别对象
    QueryBusinessInfo
    返回空模型(如车间成本计算
    CB_SFCCostCalBill
    )→ 无可查字段,不能走通用查询。
  • Use
    STK_Inventory
    (current inventory balance object) for real-time stock quantity, not
    STK_InventoryQuery
    (the latter is a query interface with no field model). This has been encapsulated as
    openerp inventory balance list
    .
  • Reports/account tables (model type 900, named with GUID, such as "Sales Order Execution Details/Sales Details"): still not supported, need to use
    GetSysReportData
    ; or reproduce using corresponding documents (e.g.,
    SAL_OUTSTOCK
    outbound details).
  • For individual objects,
    QueryBusinessInfo
    returns an empty model (e.g., workshop cost calculation
    CB_SFCCostCalBill
    ) → no queryable fields, cannot use the general query process.

objects 命令

objects Command

bash
openerp objects --keyword <名称关键词>     # 必须给收敛条件
openerp objects --subsystem <子系统>       # 按子系统过滤
openerp objects --keyword 委外 --top 30
bash
openerp objects --keyword <name keyword>     # Must provide a convergence condition
openerp objects --subsystem <subsystem>       # Filter by subsystem
openerp objects --keyword Outsourcing --top 30

schema 命令

schema Command

bash
openerp schema <FormId>               # 完整元数据
openerp schema <FormId> --fields-only # 精简字段清单(推荐)
bash
openerp schema <FormId>               # Complete metadata
openerp schema <FormId> --fields-only # Simplified field list (recommended)