Create a custom document class

From iDempiere en
Jump to: navigation, search

A "document" in iDempiere is an application concept that is very useful. Many of iDempiere's built in functions use documents for its implementation. Examples of documents are:

  • Invoices
  • Shipments
  • Inventory moves/adjustments
  • Payments

What makes documents special from other entities (such as business partners / products) are that they have a document status.

The document status enables the documents to be in a workflow and be in different statuses.

This concept is very powerful and the possibility to create new custom documents makes iDempiere even more powerful and flexible.

Steps to create a new custom document

Create the model

The "Model" is the database table representation and classes for the document's data.

  • Create a new Model (will be explained more in detail)
    • Except for the other mandatory fields the model must contain the following fields
    • C_DocType_ID numeric(10,0) NOT NULL DEFAULT 0::numeric (Reference = Table, Reference Key = C_DocType)
    • C_DocTypeTarget_ID numeric(10,0) NOT NULL DEFAULT 0::numeric
    • DocAction character varying(2) NOT NULL DEFAULT 'CO'::bpchar (Reference = Button, Process = Custom Workflow, Reference Key = _Document Action)
    • DocStatus character varying(2) NOT NULL DEFAULT 'DR'::character varying (Reference = List, Reference Key = _Document Status)
    • DocumentNo character varying(30) NOT NULL
    • processed character(1) DEFAULT 'N'::bpchar
    • processing character(1) DEFAULT 'N'::bpchar
    • isapproved character(1) NOT NULL DEFAULT 'Y'::bpchar
  • Generate the model class
  • The model class must implement DocAction.

Define the window

Define the window as you normally do. The following fields must be present to enable the document workflow.

  • Processed
  • DocStatus, set to "Read Only"
  • DocAction

Create Custom Workflow

  • Create Workflow
  • Create Node (DocComplete)
    • Action = Document Action
    • Document Action = Complete
  • Create Node (DocPrepare)
    • Action = Document Action
    • Document Action = Prepare
    • Create Transition. Next Node = (DocComplete)
  • Create Node (Start)
    • Action = Wait (Sleep)
    • Create Transition. Next Node = (DocPrepare)
  • Go back to workflow and select Start Node = (Start)
  • Set Workflow Type = Document Process
  • Table = same table as the model.