Bỏ qua để đến nội dung

OnlyOffice editor inline

OnlyOffice Document Server nhúng trong Parkone qua iframe — Sales rep / Pháp chế sửa .docx trực tiếp trong browser, không cần download → mở Word → sửa → upload lại.

Browser
├── Odoo Backend (parkone.doc.template form)
└── <iframe src="https://oo.parkone.vn/apps/documenteditor?...">
└── OnlyOffice Document Server
├── Fetch .docx via WOPI endpoint Odoo (JWT-signed)
├── Render UI edit
├── User edit → save event → POST callback Odoo
└── Sidecar plugin (postMessage) — field picker IPC
  • Template: Cấu hình → Mẫu tài liệu → chọn template
  • HĐ đã render: Bán hàng → HĐ → tab “Documents” → click file .docx

Iframe OnlyOffice load ~3-5 giây. Show UI giống Word Online:

  • Toolbar top: File, Insert, Format, Layout, Review
  • Ribbon với font, size, color, bold/italic
  • Sidebar right: Comments, Track Changes

Type, format, chèn ảnh/bảng, styles. Auto-save mỗi 10 giây (nếu bật autosave).

  • Save (Ctrl+S): save vào DB Odoo qua callback WOPI
  • File → Download as .docx: download local (optional)
  • Click X trong iframe hoặc back Odoo
  • File updated trong template / attachment

Toàn bộ Word standard:

  • Insert: Table, Image, Header/Footer, Page break, Field
  • Layout: Margins, Orientation, Columns
  • Review: Track Changes, Comments, Spellcheck
  • Format: Style, Font, Paragraph
  • File: Print, Download, Version History

Không dùng được:

  • Macros / VBA (không support server-side)
  • Mail Merge (dùng Doc Engine wizard thay)
  • External data connection (không cho phép)

Khi user click Save trong OnlyOffice:

  1. OnlyOffice edit session marks doc as saved
  2. OnlyOffice sends POST callback tới Odoo: POST /parkone/doc/<template_id>/callback
  3. Callback body: {"status": 2, "url": "https://oo.parkone.vn/cache/files/.../file.docx"}
  4. Odoo verify JWT signature
  5. Odoo download file from OnlyOffice cache URL
  6. Odoo save binary vào field template.file (hoặc attachment)
  7. Odoo respond {"error": 0} → OnlyOffice release lock

OnlyOffice ↔ Odoo authenticated via HS256 JWT:

  • Env var OO_JWT_SECRET shared giữa 2 containers
  • Odoo sign token khi gửi URL cho OnlyOffice
  • OnlyOffice sign callback với same secret
  • Nếu secret mismatch → OnlyOffice refuse render / Odoo refuse callback

Admin verify:

Terminal window
docker exec parkone-odoo bash -c 'echo $OO_JWT_SECRET'
docker exec zonepro-onlyoffice bash -c 'grep -r JWT /etc/onlyoffice/documentserver/'

Cả 2 phải có same secret.

Editor có 2 modes:

  • Toolbar full
  • Save button active
  • User có thể edit content

Trigger khi user có write access trên template + không có ai đang edit.

OnlyOffice hỗ trợ multi-user co-editing:

  • User A + B cùng mở template → cả 2 thấy avatar top-right
  • A gõ text → B thấy realtime
  • Merge conflict xử lý bởi OnlyOffice OT algorithm

Nhưng KHÔNG khuyến nghị cho template quan trọng — pháp chế nên lock 1 người edit cùng lúc.

OnlyOffice tự save version:

  • Mỗi Save → 1 version snapshot
  • View history: File → Version History
  • Rollback: chọn version cũ → Restore

Version stored trong OnlyOffice cache (7 ngày). Nếu cần long-term backup → save file .docx định kỳ.

OnlyOffice có 100+ fonts built-in. Nếu Word template dùng font Việt custom (Times New Roman OK, nhưng font unicode custom có thể miss):

  1. Admin SSH vào container OnlyOffice:
    Terminal window
    docker exec -it zonepro-onlyoffice bash
    cp custom-font.ttf /usr/share/fonts/truetype/
    fc-cache -fv
  2. Restart container: docker restart zonepro-onlyoffice
  3. Font available trong editor + render
  1. Open browser DevTools → Console tab
  2. Look for errors:
    • 403 Forbidden → JWT secret mismatch
    • 404 Not Found → WOPI endpoint sai URL
    • CORS blocked → OnlyOffice không có AllowMetaTag: true
    • ETIMEDOUT → OnlyOffice can’t reach Odoo (network issue)
  3. Cross-verify:
    • Odoo container reachable from OnlyOffice: docker exec zonepro-onlyoffice curl http://odoo:8069
    • JWT secret same on both
  • Callback endpoint down → check /parkone/doc/<id>/callback return 200 with {"error": 0}
  • Filesystem write permission → Odoo user must write to /var/lib/odoo/filestore
  • Load time: 3-5s (first time), <1s (subsequent — OnlyOffice cache)
  • Save latency: 200-500ms
  • Concurrent users per doc: 5-10 (co-edit smooth), 20+ (slow)

Nếu doc > 50 MB (ảnh nặng) → load 10-15s. Compress ảnh trước upload.

  • OnlyOffice không reach được Odoo qua network
  • Verify docker network: cả 2 phải cùng network parkone_default (hoặc parkone_managed_net)
  • Check firewall

File edit thấy {{ variable }} literal trong editor

Phần tiêu đề “File edit thấy {{ variable }} literal trong editor”
  • Đó là placeholder chưa được replace (chưa render). Editor show raw template.
  • Muốn preview render → mở HĐ → click “Render” → download output → so sánh

Muốn edit lại HĐ đã render (không phải template)?

Phần tiêu đề “Muốn edit lại HĐ đã render (không phải template)?”
  • HĐ render output là snapshot — không edit qua Doc Engine
  • Muốn edit: download .docx → mở Word → sửa → upload attachment lại

Hoặc: render lại từ template với data mới.

  • Community (free): 20 concurrent users, không SLA
  • Enterprise (paid): unlimited users, official support

Parkone dùng Community. Đủ cho hầu hết KCN.

Chia sẻ: