Email templates
Email templates
Phần tiêu đề “Email templates”Parkone dùng Odoo mail.template — templates có Jinja2 syntax + attachment support. Đại custom cho brand + nội dung.
Templates default có sẵn
Phần tiêu đề “Templates default có sẵn”| Template ID | Dùng khi | Trigger |
|---|---|---|
parkone.email_invoice_sent | Post Invoice → send email | Manual/auto sau Post |
parkone.email_reminder_before_due | 7 ngày trước hạn | Cron 07:00 |
parkone.email_reminder_overdue | Quá hạn 3 ngày | Cron 07:00 |
parkone.email_deposit_signed | KH ký Đặt cọc | Manual |
parkone.email_contract_activated | HĐ Active | Auto khi state change |
parkone.email_termination_notice | HĐ Terminate | Manual |
parkone.email_welcome_tenant | KH mới tạo | Manual |
Xem + Edit template
Phần tiêu đề “Xem + Edit template”1. Bật Dev mode
Phần tiêu đề “1. Bật Dev mode”Cài đặt → General → Bật chế độ nhà phát triển
2. Mở list templates
Phần tiêu đề “2. Mở list templates”Cấu hình → Technical → Email → Templates
3. Filter Parkone
Phần tiêu đề “3. Filter Parkone”Search bar: parkone → list các template
4. Click template cần edit
Phần tiêu đề “4. Click template cần edit”Vd Parkone: Reminder before due
5. Edit fields
Phần tiêu đề “5. Edit fields”- Subject: subject email (có Jinja:
Nhắc thanh toán HĐ ${object.name}) - From: email gửi (default
${object.company_id.email}) - To: recipient (default
${object.partner_id.email}) - CC / BCC: optional
- Body: HTML content với Jinja placeholders
- Attachment: template PDF nếu cần
- Reply-to: email nhận reply
Jinja placeholders phổ biến
Phần tiêu đề “Jinja placeholders phổ biến”Với object = account.move (Invoice)
Phần tiêu đề “Với object = account.move (Invoice)”${object.name} # Số HĐ INV-2026-125${object.amount_total_signed} # Tổng có VAT${object.amount_residual} # Còn thiếu chưa trả${object.invoice_date} # Ngày HĐ${object.invoice_date_due} # Ngày đến hạn${object.partner_id.name} # Tên KH${object.partner_id.email} # Email KH${object.company_id.name} # Tên công ty phát hành${object.company_id.email} # Email cty${format_amount(object.amount_total, object.currency_id)} # Format tiền có currency${format_date(object.invoice_date_due)} # Format date DD/MM/YYYYVới object = zone.contract (HĐ)
Phần tiêu đề “Với object = zone.contract (HĐ)”${object.name} # ZC-2026-042${object.customer_id.name}${object.total_amount}${object.date_start} - ${object.date_end}${object.lot_id.code} # Lô đất${object.project_id.name} # KCNVới object = zone.deposit.agreement
Phần tiêu đề “Với object = zone.deposit.agreement”${object.name} # DA-2026-018${object.partner_id.name}${object.deposit_amount}${object.deposit_paid_amount}Universal helpers
Phần tiêu đề “Universal helpers”${ctx.get('lang', 'vi_VN')} # Ngôn ngữ${company.name} # Company của user${user.name} # User trigger email${format_amount(1234567, currency)} # → "1,234,567 ₫"${format_date(fields.Date.today())} # → "31/12/2026"Ví dụ template hoàn chỉnh — Nhắc trước hạn
Phần tiêu đề “Ví dụ template hoàn chỉnh — Nhắc trước hạn”Subject:
[Parkone] Nhắc thanh toán HĐ ${object.name} — Hạn ${format_date(object.invoice_date_due)}Body (HTML):
<p>Kính gửi Quý khách <strong>${object.partner_id.name}</strong>,</p>
<p>Cảm ơn Quý khách đã hợp tác cùng ${object.company_id.name}.</p>
<p>Chúng tôi xin gửi thông báo về hoá đơn sắp đến hạn thanh toán:</p>
<table style="border-collapse: collapse; width: 100%; margin: 20px 0;"> <tr><td><strong>Số hoá đơn:</strong></td><td>${object.name}</td></tr> <tr><td><strong>Ngày hoá đơn:</strong></td><td>${format_date(object.invoice_date)}</td></tr> <tr><td><strong>Số tiền:</strong></td><td>${format_amount(object.amount_total, object.currency_id)}</td></tr> <tr><td><strong>Hạn thanh toán:</strong></td><td>${format_date(object.invoice_date_due)}</td></tr></table>
<p>Vui lòng thanh toán trước ngày <strong>${format_date(object.invoice_date_due)}</strong> để tránh phát sinh phí phạt theo Điều X HĐ.</p>
<p><strong>Tài khoản ngân hàng nhận:</strong></p><ul> <li>Số TK: ${object.company_id.partner_id.bank_acc_vnd_id.acc_number}</li> <li>Ngân hàng: ${object.company_id.partner_id.bank_acc_vnd_id.bank_id.name}</li> <li>Chủ TK: ${object.company_id.name}</li> <li>Nội dung CK: <strong>${object.name}</strong></li></ul>
<p>Nếu Quý khách đã thanh toán, xin bỏ qua email này.</p>
<p>Trân trọng,<br/><strong>${object.company_id.name}</strong><br/>${object.company_id.email} · ${object.company_id.phone}</p>Attachment PDF
Phần tiêu đề “Attachment PDF”Template có thể attach PDF Invoice:
- Edit template → tab Report attachment
- Field Report: chọn action report
account.report_invoice_with_payments(Invoice PDF chuẩn) - Field Report Name:
Invoice_${object.name}.pdf(Jinja OK) - Save
Khi trigger send email, Odoo auto-render report PDF + attach.
Multi-language
Phần tiêu đề “Multi-language”Nếu KH FDI cần email tiếng Anh:
- Template có field Language =
${object.partner_id.lang} - Odoo auto-detect ngôn ngữ KH:
- VN → dùng translation
vi_VN - EN → dùng translation
en_US - Không có translation → fallback default
- VN → dùng translation
- Đại thêm translation cho template:
- Icon 🌐 bên cạnh field Body → chọn ngôn ngữ → paste translation
Test send
Phần tiêu đề “Test send”- Open template → click “Send Preview” (nút icon envelope)
- Chọn record test (vd Invoice INV-2026-001)
- Email preview render đúng data
- Đại có thể “Send to me” để thử vào email
Custom template mới
Phần tiêu đề “Custom template mới”Vd tạo template “Chúc mừng KH ký HĐ”:
- Cấu hình → Technical → Email → Templates → Mới
- Điền:
- Name:
Parkone: Contract signed congrats - Model:
zone.contract - Subject:
Chúc mừng ký HĐ ${object.name} — Chào mừng đến với ${object.company_id.name}! - Body: HTML với Jinja
- Attachment: contract PDF report
- Name:
- Save
Sử dụng:
- Manual trigger: mở Contract → menu Action → “Send by Email” → chọn template mới
- Auto trigger: cần automation rule (Cấu hình → Technical → Automation)
Best practices
Phần tiêu đề “Best practices”Placeholder render False hoặc empty
Phần tiêu đề “Placeholder render False hoặc empty”- Field không tồn tại → check spell (Odoo case-sensitive)
- Field is Many2one → phải dùng
.namesau:${object.partner_id.name}không phải${object.partner_id} - Field is bool False → check tồn tại:
${object.paid and 'Đã trả' or 'Chưa trả'}
Muốn attach nhiều file
Phần tiêu đề “Muốn attach nhiều file”Trong template, field Report: chỉ 1 report. Muốn nhiều → custom Python context.attachment_ids (Advanced).
Or: send 2 emails riêng biệt.
Trigger email khi record đổi state
Phần tiêu đề “Trigger email khi record đổi state”Cần Automation Rule:
- Cấu hình → Technical → Automation → Automated Actions → Mới
- Model:
zone.contract - Trigger: On update
- Filter:
state = 'active' - Action: Send Email → chọn template