CT01VILP ERP nội bộ Về màn hình duyệt

Hướng dẫn tích hợp Odoo

Kỹ thuật

Odoo gửi phiếu ở trạng thái Done qua HTTPS. Các yêu cầu có body dùng Content-Type: application/json và UTF-8. Tài khoản tích hợp được gán companyCode mặc định là CT01VILP (trường companyCode trong JSON nên gửi "CT01VILP"; nếu bỏ trống hệ thống tự lấy theo tài khoản đăng nhập).

Đăng nhập và quản lý phiên

Phương thức và đường dẫnDữ liệu gửiKết quả
POST /api/auth/login{"username":"TÀI_KHOẢN_ERP","password":"MẬT_KHẨU"}data.accessToken và data.refreshToken cùng thời hạn.
POST /api/auth/refresh{"refreshToken":"REFRESH_TOKEN"}Cặp token mới. Dùng cặp mới cho các yêu cầu tiếp theo.
DELETE /api/auth/sessionHeader Authorization: Bearer ACCESS_TOKENThu hồi phiên.

Access token có hiệu lực tối đa 15 phút. Phiên hết hạn sau 24 giờ kể từ đăng nhập. Mỗi lần refresh thay cả hai token.

Nhóm API và 8 loại chứng từ ERP

Nhóm APIGiá trị documentTypeNghiệp vụ ERP
/api/receiptsPURCHASE_DOMESTIC, PURCHASE_IMPORT, SALES_RETURN, STOCK_RECEIPTMua hàng nội địa, Mua hàng nhập khẩu, Hàng bán trả lại, Nhập kho
/api/shipmentsSUPPLIER_RETURN, SALES_INVOICE, STOCK_ISSUEHàng trả lại NCC, Hóa đơn bán hàng, Xuất kho
/api/transfersSTOCK_TRANSFERChuyển kho

Dùng POST để tạo, GET /{requestId} để tra cứu đầy đủ đầu phiếu và dòng, PUT /{requestId} để cập nhật khi phiếu còn PENDING kèm revision mới nhất. API kiểm tra ngay các trường bắt buộc và độ dài cột ERP khi POST/PUT.

Trường bắt buộc theo từng loại phiếu

Loại phiếuĐầu phiếu bắt buộcTừng dòng trong lines[] bắt buộc
Mọi loại phiếusourceId, documentType, documentDate (YYYY-MM-DD), referenceNo (tùy chọn companyCode mặc định CT01VILP)sourceLineId, itemCode, quantity (> 0, tối đa 4 số lẻ)
STOCK_TRANSFERfromWarehouseCode, toWarehouseCode (khác kho nguồn), movementCode (max 10)inventoryAccount, toInventoryAccount (thêm lot/property/property2 nếu mã hàng quản lý)
STOCK_RECEIPT, STOCK_ISSUEmovementCode (max 20)warehouseCode, inventoryAccount, offsetAccount (có thể gửi unitPrice)
PURCHASE_DOMESTIC, PURCHASE_IMPORTpartnerCode, currencyCode (3 ký tự), exchangeRate, controlAccount (TK phải trả), vatAccount (+ importDutyAccount/additionalImportDutyAccount nếu có thuế NK)warehouseCode, inventoryAccount, purchaseCostAccount, vatCode, unitPrice, sourceAmount, amount, vatAmount, totalAmount
SUPPLIER_RETURNpartnerCode, currencyCode, exchangeRate, controlAccount, vatAccount (+ originalErpDocumentId nếu trả theo phiếu mua)warehouseCode, inventoryAccount, vatCode, unitPrice, sourceAmount, amount, vatAmount, totalAmount (+ originalErpLineId nếu đối chiếu dòng)
SALES_INVOICEpartnerCode, currencyCode, exchangeRate, controlAccount (TK phải thu), vatAccountwarehouseCode, inventoryAccount, incomeAccount, costOfSalesAccount, vatCode, unitPrice, sourceAmount, amount, vatAmount, totalAmount
SALES_RETURNpartnerCode, currencyCode, exchangeRate, controlAccount, vatAccount (+ originalErpDocumentId nếu trả theo hóa đơn)warehouseCode, inventoryAccount, returnAccount, costOfSalesAccount, vatCode, unitPrice, sourceAmount, amount, vatAmount, totalAmount

Trường ERP bổ sung được hỗ trợ đầy đủ

Phạm viTên trường JSON
Đầu phiếu chungmemo, notes, branchCode, toBranchCode, employeeCode, movementCode, deliver (người giao), receiver (người nhận), orderNumber (PO), contractCode, originalErpDocumentId, paymentTypeCode, paymentTermCode, dueDate, attach, attachDate, costCenterCode, costCode, locationCode, productOrderCode
Nhập khẩu / Kho / Bán hàngincotermCode, customsDeclarationNo, customsDeclarationDate, importDutyAccount3, importDutyAccount4, expenseAccount, isExport, exportVatAccount, calPrice, calCost, isPacket, voucherNo, voucherDate, inspectionNo, inspectionDate, invoiceContent, invoiceBuyer, retailCustomerName, retailCustomerTaxCode
Tổng tiền & Hóa đơn thuếamountTotal, vatAmountTotal, importAmountTotal, discountTotal, otherFeeTotal, baseTotal, invoiceNumber (tối đa 20 ký tự cho bán hàng khi có taxInvoice), taxInvoice: {"serial","date","legalName","address","taxCode","itemCaption","formCode","link"}
Dòng chi tiết (lines[])unit, unit2, unitFactor, quantity2, lot, expireDate, property, property2, unitPriceVnd, unitCost, amountCost, discountPercent, discountAmount, cashDiscountPercent, cashDiscountAmount, discountAmount2, discountAccount, vatPercent, importDutyRate, importDuty, additionalImportDutyRate, additionalImportDuty, exportDutyRate, exportDuty, purchaseCost, otherFee, otherFeeAccount, fobPrice, fobAmount, preCustomsFeeFC, preCustomsFeeLC, customsValue, importVatBase, importVatRate, importVatAmount, costCenterCode, costCode, originalErpLineId, poSoi, poVai, orderNumber, productOrderCode, productCode, description, equipId, packetGroup, partSerialNo, assetId, notes
{
  "companyCode": "CT01VILP",
  "sourceId": "SO/2026/0001",
  "documentType": "SALES_INVOICE",
  "documentDate": "2026-11-25",
  "referenceNo": "SO/2026/0001",
  "partnerCode": "KH001",
  "employeeCode": "NV01",
  "currencyCode": "VND",
  "exchangeRate": 1,
  "controlAccount": "131",
  "vatAccount": "33311",
  "orderNumber": "PO-KH-01",
  "memo": "Bán vải thành phẩm",
  "invoiceNumber": "00000123",
  "taxInvoice": {
    "serial": "1C26TYY",
    "date": "2026-11-25",
    "legalName": "Công ty ABC",
    "address": "TP.HCM",
    "taxCode": "0300000000"
  },
  "lines": [
    {
      "sourceLineId": "L1",
      "itemCode": "VAI-01",
      "warehouseCode": "KHO-TP",
      "quantity": 100,
      "unitPrice": 50000,
      "sourceAmount": 5000000,
      "amount": 5000000,
      "vatCode": "V10",
      "vatAmount": 500000,
      "totalAmount": 5500000,
      "inventoryAccount": "155",
      "incomeAccount": "5111",
      "costOfSalesAccount": "632",
      "poSoi": "SOI-2601",
      "poVai": "VAI-2601",
      "productOrderCode": "LSX-001"
    }
  ]
}
HTTPMã và cách xử lý
400INVALID_DOCUMENT, INVALID_LINES, INVALID_JSON. Thiếu trường bắt buộc ERP, sai độ dài hoặc sai nhóm API.
401AUTH_REQUIRED. Cấp lại access token hoặc đăng nhập lại.
403 / 404FORBIDDEN, REQUEST_NOT_FOUND. Kiểm tra quyền và mã phiếu.
409SOURCE_CONFLICT, REVISION_CONFLICT, REQUEST_LOCKED, ERP_PERIOD_CLOSED, ERP_INSUFFICIENT_STOCK.
413 / 429BODY_TOO_LARGE (512 KiB), LOGIN_RATE_LIMIT.
422ERP_INVALID_DOCUMENT, ERP_INVALID_TRANSFER. Lệch danh mục, tài khoản, lô/thuộc tính hoặc tiền-thuế trên ERP.

Kế toán

  1. Đăng nhập bằng tài khoản ERP có quyền duyệt và chọn nhóm nhập hàng, xuất hàng hoặc chuyển kho.
  2. Mở một phiếu đang Chờ duyệt. Đối chiếu đầy đủ thông tin master trên panel Thông tin duyệt và chi tiết hàng hóa bên dưới.
  3. Bấm Duyệt để ghi chứng từ vào các bảng ERP và khóa phiếu ở trạng thái Đã duyệt.
  4. Khi không duyệt, nhập lý do (nếu có) và bấm Không duyệt; phiếu chuyển sang Không duyệt và khóa lại.