openerp-discovery
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
Chineseopenerp-discovery — 发现任意业务对象的查询方式
openerp-discovery — Discover Query Methods for Any Business Object
先读(鉴权、退出码、输出契约)。../openerp-shared/SKILL.md
金蝶业务对象上千个。发现层让你在运行期查到任意对象,无需等领域命令封装。高频对象已有领域命令(见 ),其余一律走这套三步发现。
../openerp-domains/SKILL.mdFirst read(Authentication, Exit Codes, Output Contracts).../openerp-shared/SKILL.md
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 ), while all other objects follow this three-step discovery process.
../openerp-domains/SKILL.md三步发现工作流
Three-Step Discovery Workflow
bash
undefinedbash
undefined1) 找对象 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
--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
--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(会报“标识为 FEntity 的字段不存在”)。FSaleOrderEntry.FQty - 关联字段用点号下钻:、
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), do not writeFQty/FEntity.FMaterialId(this will trigger an error "Field identified as FEntity does not exist").FSaleOrderEntry.FQty - Drill down related fields with dots: ,
FSupplierId.FName,FMaterialId.FNumber. If theFCustId.FNumberof 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.lookUpForm - Field names are case-sensitive, take the actual schema output as the standard (the same concept may be /
FMaterialId/FMATERIALIDin different documents).FMaterialID - Queries must include filters or --top to avoid full table scans; use for results exceeding 2000 rows.
--page-all - If an entire column of a field is : this is mostly due to lack of data permissions or incorrect field spelling → go back to
nullto verify.schema
命名陷阱与不支持项
Naming Pitfalls and Unsupported Items
- 即时库存现量用 (现存量余额对象),不是
STK_Inventory(后者是查询界面,无字段模型)。已封装为STK_InventoryQuery。openerp inventory balance list - 报表/账表(模型类型 900、GUID 命名,如“销售订单执行明细表/销售明细表”):仍不支持,需 ;或改用对应单据(如
GetSysReportData出库明细)复现。SAL_OUTSTOCK - 个别对象 返回空模型(如车间成本计算
QueryBusinessInfo)→ 无可查字段,不能走通用查询。CB_SFCCostCalBill
- Use (current inventory balance object) for real-time stock quantity, not
STK_Inventory(the latter is a query interface with no field model). This has been encapsulated asSTK_InventoryQuery.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 ; or reproduce using corresponding documents (e.g.,
GetSysReportDataoutbound details).SAL_OUTSTOCK - For individual objects, returns an empty model (e.g., workshop cost calculation
QueryBusinessInfo) → no queryable fields, cannot use the general query process.CB_SFCCostCalBill
objects 命令
objects Command
bash
openerp objects --keyword <名称关键词> # 必须给收敛条件
openerp objects --subsystem <子系统> # 按子系统过滤
openerp objects --keyword 委外 --top 30bash
openerp objects --keyword <name keyword> # Must provide a convergence condition
openerp objects --subsystem <subsystem> # Filter by subsystem
openerp objects --keyword Outsourcing --top 30schema 命令
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)