Openbravo开发-开发篇 为模型建立一张表

在模型被注册后,首先建立模型需要的表
1)建立表结构
可以使用各种数据库工具
属于这个模型的表必须使用预先定义的前缀。包括table, trigger, stored procedure
表必须包括以下字段 AD_Client_ID, AD_Org_ID, IsActive, Created, CreatedBy, Updated and UpdatedBy
例子如下
PostgreSQL
CREATE TABLE HR_SALARY
(
  HR_SALARY_ID  CHARACTER VARYING(32) NOT NULL,
  AD_CLIENT_ID  CHARACTER VARYING(32) NOT NULL,
  AD_ORG_ID     CHARACTER VARYING(32) NOT NULL,
  ISACTIVE      CHARACTER(1)                   NOT NULL        DEFAULT 'Y',
  CREATED       TIMESTAMP WITHOUT TIME ZONE NOT NULL DEFAULT now(),
  CREATEDBY     CHARACTER VARYING(32) NOT NULL,
  UPDATED       TIMESTAMP WITHOUT TIME ZONE NOT NULL DEFAULT now(),
  UPDATEDBY     CHARACTER VARYING(32)         NOT NULL,
  C_BPARTNER_ID CHARACTER VARYING(32)         NOT NULL,
  AMOUNT NUMERIC               NOT NULL,
  C_CURRENCY_ID VARCHAR(32)                 NOT NULL,
  VALIDFROM     TIMESTAMP WITHOUT TIME ZONE    NOT NULL,
    CONSTRAINT HRSALARY_ISACTIVE_CHECK CHECK (isactive = ANY (ARRAY['Y'::bpchar, 'N'::bpchar])),
    CONSTRAINT HR_SALARY_KEY PRIMARY KEY (HR_SALARY_ID),
    CONSTRAINT AD_ORG_CUS_PROJECT FOREIGN KEY (AD_ORG_ID)
     REFERENCES AD_ORG (AD_ORG_ID),
    CONSTRAINT AD_CLIENT_CUS_PROJECT FOREIGN KEY (AD_CLIENT_ID)
     REFERENCES AD_CLIENT (AD_CLIENT_ID),
    CONSTRAINT C_BPARTNER_HR_SALARY FOREIGN KEY (C_BPARTNER_ID)
     REFERENCES C_BPARTNER (C_BPARTNER_ID),
    CONSTRAINT C_BPARTNER_C_CURRENCY FOREIGN KEY (C_CURRENCY_ID)
     REFERENCES C_CURRENCY (C_CURRENCY_ID)
);
2)在AD中注册表
into Openbravo ERP using a username with access to System Administrator role. Navigate to Application Dictionary || Tables and Columns
填写表名后,按 Create columns from DB按钮,系统自动取出column
在Application Dictionary || Synchronize Terminology中运行 Synchronize Terminology process 过程,系统自动同步column 和element
大部分能自动匹配,以下需要手工匹配
Amount: Reference = Amount, Length = 10
C_BPartner_ID: Reference = Search, Reference Search Key = Business Partner, Length = 32, Link To Parent Column = Y
Valid From: Identifier = Y
Amount: Identifier = Y

你可能感兴趣的:(数据结构,C++,c,C#,PostgreSQL)