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

Email templates

Parkone dùng Odoo mail.template — templates có Jinja2 syntax + attachment support. Đại custom cho brand + nội dung.

Template IDDùng khiTrigger
parkone.email_invoice_sentPost Invoice → send emailManual/auto sau Post
parkone.email_reminder_before_due7 ngày trước hạnCron 07:00
parkone.email_reminder_overdueQuá hạn 3 ngàyCron 07:00
parkone.email_deposit_signedKH ký Đặt cọcManual
parkone.email_contract_activatedHĐ ActiveAuto khi state change
parkone.email_termination_noticeHĐ TerminateManual
parkone.email_welcome_tenantKH mới tạoManual

Cài đặt → General → Bật chế độ nhà phát triển

Cấu hình → Technical → Email → Templates

Search bar: parkone → list các template

Vd Parkone: Reminder before due

  • 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
${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/YYYY
${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} # KCN
${object.name} # DA-2026-018
${object.partner_id.name}
${object.deposit_amount}
${object.deposit_paid_amount}
${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>

Template có thể attach PDF Invoice:

  1. Edit template → tab Report attachment
  2. Field Report: chọn action report account.report_invoice_with_payments (Invoice PDF chuẩn)
  3. Field Report Name: Invoice_${object.name}.pdf (Jinja OK)
  4. Save

Khi trigger send email, Odoo auto-render report PDF + attach.

Nếu KH FDI cần email tiếng Anh:

  1. Template có field Language = ${object.partner_id.lang}
  2. 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
  3. Đại thêm translation cho template:
    • Icon 🌐 bên cạnh field Body → chọn ngôn ngữ → paste translation
  1. Open template → click “Send Preview” (nút icon envelope)
  2. Chọn record test (vd Invoice INV-2026-001)
  3. Email preview render đúng data
  4. Đại có thể “Send to me” để thử vào email

Vd tạo template “Chúc mừng KH ký HĐ”:

  1. Cấu hình → Technical → Email → Templates → Mới
  2. Đ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
  3. 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)
  • Field không tồn tại → check spell (Odoo case-sensitive)
  • Field is Many2one → phải dùng .name sau: ${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ả'}

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.

Cần Automation Rule:

  1. Cấu hình → Technical → Automation → Automated Actions → Mới
  2. Model: zone.contract
  3. Trigger: On update
  4. Filter: state = 'active'
  5. Action: Send Email → chọn template
Chia sẻ: