OnlyOffice editor inline
OnlyOffice editor inline
Phần tiêu đề “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.
Kiến trúc
Phần tiêu đề “Kiến trúc”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 IPCMở editor
Phần tiêu đề “Mở editor”1. Mở template hoặc HĐ đã render
Phần tiêu đề “1. Mở template hoặc HĐ đã render”- 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
2. Click nút “🖊️ Edit inline”
Phần tiêu đề “2. Click nút “🖊️ Edit inline””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
3. Edit như Word
Phần tiêu đề “3. Edit như Word”Type, format, chèn ảnh/bảng, styles. Auto-save mỗi 10 giây (nếu bật autosave).
4. Save
Phần tiêu đề “4. Save”- Save (Ctrl+S): save vào DB Odoo qua callback WOPI
- File → Download as .docx: download local (optional)
5. Close
Phần tiêu đề “5. Close”- Click X trong iframe hoặc back Odoo
- File updated trong template / attachment
Toolbar features
Phần tiêu đề “Toolbar features”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)
Save callback flow
Phần tiêu đề “Save callback flow”Khi user click Save trong OnlyOffice:
- OnlyOffice edit session marks doc as
saved - OnlyOffice sends POST callback tới Odoo:
POST /parkone/doc/<template_id>/callback - Callback body:
{"status": 2, "url": "https://oo.parkone.vn/cache/files/.../file.docx"} - Odoo verify JWT signature
- Odoo download file from OnlyOffice cache URL
- Odoo save binary vào field
template.file(hoặc attachment) - Odoo respond
{"error": 0}→ OnlyOffice release lock
JWT authentication
Phần tiêu đề “JWT authentication”OnlyOffice ↔ Odoo authenticated via HS256 JWT:
- Env var
OO_JWT_SECRETshared 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:
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.
Access modes
Phần tiêu đề “Access modes”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.
- Toolbar minimal (Print, Download)
- Save disabled
- Read-only
Trigger khi:
- User không có write access
- Có user khác đang edit (lock)
- Template state = archived
Concurrent edit
Phần tiêu đề “Concurrent 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.
Version history
Phần tiêu đề “Version history”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ỳ.
Font support
Phần tiêu đề “Font support”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):
- Admin SSH vào container OnlyOffice:
Terminal window docker exec -it zonepro-onlyoffice bashcp custom-font.ttf /usr/share/fonts/truetype/fc-cache -fv - Restart container:
docker restart zonepro-onlyoffice - Font available trong editor + render
Debug editor không load
Phần tiêu đề “Debug editor không load”Symptom: iframe blank / infinite loading
Phần tiêu đề “Symptom: iframe blank / infinite loading”- Open browser DevTools → Console tab
- Look for errors:
403 Forbidden→ JWT secret mismatch404 Not Found→ WOPI endpoint sai URLCORS blocked→ OnlyOffice không cóAllowMetaTag: trueETIMEDOUT→ OnlyOffice can’t reach Odoo (network issue)
- Cross-verify:
- Odoo container reachable from OnlyOffice:
docker exec zonepro-onlyoffice curl http://odoo:8069 - JWT secret same on both
- Odoo container reachable from OnlyOffice:
Symptom: Edit fine but Save fails
Phần tiêu đề “Symptom: Edit fine but Save fails”- Callback endpoint down → check
/parkone/doc/<id>/callbackreturn 200 with{"error": 0} - Filesystem write permission → Odoo user must write to /var/lib/odoo/filestore
Performance
Phần tiêu đề “Performance”- 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.
Best practices
Phần tiêu đề “Best practices”Save fail với “callback timeout”
Phần tiêu đề “Save fail với “callback timeout””- OnlyOffice không reach được Odoo qua network
- Verify docker network: cả 2 phải cùng network
parkone_default(hoặcparkone_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.
OnlyOffice free vs Enterprise
Phần tiêu đề “OnlyOffice free vs Enterprise”- Community (free): 20 concurrent users, không SLA
- Enterprise (paid): unlimited users, official support
Parkone dùng Community. Đủ cho hầu hết KCN.