AI Approval System and Integrations
To ensure the safety and compliance of core corporate data, AI GO includes a built-in "Approval System (Approvals)". This system integrates closely with database tables to intercept unauthorized changes and supports developer integrations in Custom Apps and external APIs.
1. Operational Principles of the Approval System
In traditional ERPs, when adding a leave request, sales order, or accounting voucher, the data is immediately written and takes effect in the database. In AI GO:
- Write Interception (Interceptor): When the administrator enables an approval workflow for a table, data written by colleagues or APIs is intercepted automatically and kept in a "Pending" status.
- Dispatching to Qualified Approvers: The system automatically determines and notifies qualified approvers based on workflow rules, generating an associated
ApprovalRequest. - Final Approval Callback: Only when all stages are approved by qualified approvers will the backend automatically trigger the callback action. This formally updates the database tables (e.g., changing the sales order status to "Confirmed" and automatically triggering accounting invoicing and inventory deductions). If rejected at any stage, the data reverts to draft or rejected status.
2. Setting Up Approval Workflows
Management colleagues can configure tenant-specific approval workflows in the global Dashboard.
- Entering Path: Click "Approval Workflows" under the "Organization and Access Control" section in the left navigation bar.
Configuration Steps
- Specify Target Model: Select the underlying database table to apply the workflow (e.g., Sales Order
sale.order, Leave Requesthr.leave, Vendor Billaccount.move). Note: A table can only be bound to one active Workflow at a time. - Set Trigger Conditions: Set conditions under which the approval process is triggered (e.g., purchase orders exceeding 100,000 USD require manager approval).
- Plan Approval Stages: Establish sequential approval stages (e.g., Stage 1: Department Manager, Stage 2: CFO). Each stage can be set as "Required" and configured with approval types (such as single-person approval or joint signatures).
- Define Approver Rules: Assign approver qualifications for each stage. The system supports three rules:
- Specific User: Designate specific user accounts as approvers.
- Designated Role: Assign to all colleagues possessing a specific security role (e.g., all finance managers).
- Dynamic Department Leader: Dynamic dispatching based on the "department manager of the applicant", supporting up-chain tracing levels.
3. Custom App and API Approval Integration
A key feature of the AI GO approval system is that it runs seamlessly not only in the main Dashboard, but also within Custom Apps and external APIs.
Integrating in Custom Apps
- Pending List: When managers log in to daily operational Custom Apps, a prominent "Pending Approvals" list notifies them of items awaiting their signature.
- Approval Panel Component (ApprovalPanel): Developers can embed the built-in
ApprovalPanelcomponent into detail pages in Custom Apps. Approvers can view historical tracks, input comments, and click Approve or Reject directly within the component, without leaving the App.
Integrating via APIs
AI GO provides a set of clean API endpoints to integrate approvals with external systems:
- Query Approval Status:
GET /api/v1/approvals/record/{res_model}/{res_id}Get the approval status of a specific record (such as a leave request UUID). It returns details of each stage, approver names, comments, and timestamps. - Execute Approval:
POST /api/v1/approvals/{request_line_id}/approveApprove by passing the approval line ID and comment. The system verifies if the current user is a qualified approver for this stage. If it is the final stage, the backend executes the callback automatically. - Execute Rejection:
POST /api/v1/approvals/{request_line_id}/rejectReject the approval. The original record is reset to draft status automatically, allowing employees to modify and resubmit it. - Manual Callback Retry:
POST /api/v1/approvals/{request_id}/retryIf approvals are fully passed but the callback fails due to external database connection issues, administrators can trigger this API manually to retry the callback and resolve maintenance exceptions.