Skip ke Konten
Odoo Menu
  • Login
  • Uji coba gratis
  • Aplikasi
    Keuangan
    • Akuntansi
    • Faktur
    • Pengeluaran
    • Spreadsheet (BI)
    • Dokumen
    • Tanda Tangan
    Sales
    • CRM
    • Sales
    • POS Toko
    • POS Restoran
    • Langganan
    • Rental
    Website
    • Website Builder
    • eCommerce
    • Blog
    • Forum
    • Live Chat
    • eLearning
    Rantai Pasokan
    • Inventaris
    • Manufaktur
    • PLM
    • Purchase
    • Maintenance
    • Kualitas
    Sumber Daya Manusia
    • Karyawan
    • Rekrutmen
    • Cuti
    • Appraisal
    • Referensi
    • Armada
    Marketing
    • Social Marketing
    • Email Marketing
    • SMS Marketing
    • Acara
    • Otomatisasi Marketing
    • Survei
    Layanan
    • Project
    • Timesheet
    • Layanan Lapangan
    • Meja Bantuan
    • Planning
    • Appointment
    Produktivitas
    • Diskusi
    • Approval
    • IoT
    • VoIP
    • Pengetahuan
    • WhatsApp
    Aplikasi pihak ketiga Odoo Studio Platform Odoo Cloud
  • Industri-Industri
    Retail
    • Toko Buku
    • Toko Baju
    • Toko Furnitur
    • Toko Kelontong
    • Toko Hardware
    • Toko Mainan
    Makanan & Hospitality
    • Bar dan Pub
    • Restoran
    • Fast Food
    • Rumah Tamu
    • Distributor Minuman
    • Hotel
    Real Estate
    • Agensi Real Estate
    • Firma Arsitektur
    • Konstruksi
    • Estate Management
    • Perkebunan
    • Asosiasi Pemilik Properti
    Konsultansi
    • Firma Akuntansi
    • Mitra Odoo
    • Agensi Marketing
    • Firma huku
    • Talent Acquisition
    • Audit & Sertifikasi
    Manufaktur
    • Tekstil
    • Logam
    • Perabotan
    • Makanan
    • Brewery
    • Corporate Gift
    Kesehatan & Fitness
    • Sports Club
    • Toko Kacamata
    • Fitness Center
    • Wellness Practitioners
    • Farmasi
    • Salon Rambut
    Perdagangan
    • Handyman
    • IT Hardware & Support
    • Sistem-Sistem Energi Surya
    • Pembuat Sepatu
    • Cleaning Service
    • Layanan HVAC
    Lainnya
    • Organisasi Nirlaba
    • Agen Lingkungan
    • Rental Billboard
    • Fotografi
    • Penyewaan Sepeda
    • Reseller Software
    Browse semua Industri
  • Komunitas
    Belajar
    • Tutorial-tutorial
    • Dokumentasi
    • Sertifikasi
    • Pelatihan
    • Blog
    • Podcast
    Empower Education
    • Program Edukasi
    • Game Bisnis 'Scale Up!'
    • Kunjungi Odoo
    Dapatkan Softwarenya
    • Download
    • Bandingkan Edisi
    • Daftar Rilis
    Kolaborasi
    • Github
    • Forum
    • Acara
    • Terjemahan
    • Menjadi Partner
    • Layanan untuk Partner
    • Daftarkan perusahaan Akuntansi Anda.
    Dapatkan Layanan
    • Temukan Mitra
    • Temukan Akuntan
    • Temui penasihat
    • Layanan Implementasi
    • Referensi Pelanggan
    • Bantuan
    • Upgrades
    Github Youtube Twitter Linkedin Instagram Facebook Spotify
    +1 (650) 691-3277
    Dapatkan demo
  • Harga
  • Bantuan

Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:

  • CRM
  • e-Commerce
  • Akuntansi
  • Inventaris
  • PoS
  • Project
  • MRP
All apps
Anda harus terdaftar untuk dapat berinteraksi di komunitas.
Semua Post Orang Lencana-Lencana
Label (Lihat semua)
odoo accounting v14 pos v15
Mengenai forum ini
Anda harus terdaftar untuk dapat berinteraksi di komunitas.
Semua Post Orang Lencana-Lencana
Label (Lihat semua)
odoo accounting v14 pos v15
Mengenai forum ini
Help

Dynamic Links

Langganan

Dapatkan notifikasi saat terdapat aktivitas pada post ini

Pertanyaan ini telah diberikan tanda
dynamicemail_templatev18CommunityEditiondynamic fielddynamicPlaceholderdynamicLink
1 Balas
1664 Tampilan
Avatar
Shreya Doodipala

How to add a dynamic hyperlink to a lead in the CRM in an email template?

  1. I have an email sent when a new lead is created, and I want to a link to the lead.
  2. I have a One2many secondary_sales_ids field and I want to send an email (from the secondary sales model) with the lead's link when a new secondary salesperson is added.

Odoo v18 Community edition

0
Avatar
Buang
Avatar
DataInteger Consultancy Services LLP
Jawaban Terbai

To add a dynamic hyperlink to a lead in the CRM in Odoo 18 Community Edition , and send it via email from the secondary sales model (when a new secondary salesperson is added) , follow these  steps :


STEP 1: Construct the Lead Link in the Email Template

Odoo dynamically renders links using templating language ( ${object.field} , t-esc , t-href , etc.). Here's how to insert a dynamic link to a lead:


Option A: If you're sending the email via a QWeb Email Template

Use this in your email body:

<p>
    View the Lead:
    <a t-attf-href="${object.lead_id.get_base_url()}/web#id=${object.lead_id.id}&model=crm.lead&view_type=form">
        ${object.lead_id.name}
    </a>
</p>
  • object.lead_id is the Many2one field in your secondary.salesperson model linking to crm.lead .
  • get_base_url() returns the base domain, eg, http://localhost:8069 .

Option B: If you're writing the email content manually in Python (from code)

Use this approach when sending email via code (eg, message_post , mail.template triggered by Python):

lead_url = f"{lead_id.get_base_url()}/web#id={lead_id.id}&model=crm.lead&view_type=form"
body = f"""
<p>Hello,</p>
<p>A new lead has been assigned to you.</p>
<p>Click here to view it: <a href="{lead_url}">{lead_id.name}</a></p>
"""
# Now send this body via mail.template or message_post

STEP 2: Add Email Sending Logic in create() of secondary.salesperson

In your secondary.salesperson model ( secondary_sales_ids ), override the create method to send the email when a record is added:

from odoo import models, fields, api

class SecondarySalesperson(models.Model):
    _name = 'your.secondary.salesperson.model'

    lead_id = fields.Many2one('crm.lead', string='Lead')
    user_id = fields.Many2one('res.users', string='Secondary Salesperson')

    @api.model
    def create(self, vals):
        record = super().create(vals)
        if record.lead_id:
            template = self.env.ref('your_module_name.email_template_secondary_sales_lead_link')
            template.send_mail(record.id, force_send=True)
        return record
STEP 3: Define the Email Template (in XML)
<record id="email_template_secondary_sales_lead_link" model="mail.template">
    <field name="name">Lead Assigned to Secondary Salesperson</field>
    <field name="model_id" ref="your_module.model_your_secondary_salesperson_model"/>
    <field name="subject">New Lead Assigned: ${object.lead_id.name}</field>
    <field name="email_from">${(user.email or 'noreply@example.com')|safe}</field>
    <field name="email_to">${object.user_id.email|safe}</field>
    <field name="body_html" type="html">
        <![CDATA[
        <p>Hello ${object.user_id.name},</p>
        <p>You have been assigned to a new lead.</p>
        <p>Lead: <strong>${object.lead_id.name}</strong></p>
        <p>
            Click here to open the lead:
            <a t-attf-href="${object.lead_id.get_base_url()}/web#id=${object.lead_id.id}&model=crm.lead&view_type=form">
                ${object.lead_id.name}
            </a>
        </p>
        ]]>
    </field>
</record>
Final Notes:
  • Replace your.secondary.salesperson.model with your actual model name (like crm.lead.secondary.salesperson ).
  • Replace your_module_name with the name of your custom module.


Thanks & Regards,

Email: contact@datainteger.com

0
Avatar
Buang
Menikmati diskusi? Jangan hanya membaca, ikuti!

Buat akun sekarang untuk menikmati fitur eksklufi dan agar terlibat dengan komunitas kami!

Daftar
Post Terkait Replies Tampilan Aktivitas
Modify Pivot View
Pivot v18 CommunityEdition
Avatar
Avatar
1
Jun 25
1741
Unable to send email notifications through write
notifications v18 CommunityEdition
Avatar
Avatar
1
Jun 25
1794
Hide Records based on user group only in a particular view
views record_rule v18 CommunityEdition
Avatar
Avatar
Avatar
2
Sep 25
1473
Unable to pass context to an action
context server_action v18 CommunityEdition
Avatar
Avatar
1
Jul 25
1621
Hide menus in user_menuitems from specific users
visibility v18 CommunityEdition user_menuitem
Avatar
Avatar
Avatar
3
Jul 25
2113
Komunitas
  • Tutorial-tutorial
  • Dokumentasi
  • Forum
Open Source
  • Download
  • Github
  • Runbot
  • Terjemahan
Layanan
  • Odoo.sh Hosting
  • Bantuan
  • Peningkatan
  • Custom Development
  • Pendidikan
  • Temukan Akuntan
  • Temukan Mitra
  • Menjadi Partner
Tentang Kami
  • Perusahaan kami
  • Aset Merek
  • Hubungi kami
  • Tugas
  • Acara
  • Podcast
  • Blog
  • Pelanggan
  • Hukum • Privasi
  • Keamanan
الْعَرَبيّة Català 简体中文 繁體中文 (台灣) Čeština Dansk Nederlands English Suomi Français Deutsch हिंदी Bahasa Indonesia Italiano 日本語 한국어 (KR) Lietuvių kalba Język polski Português (BR) română русский язык Slovenský jazyk slovenščina Español (América Latina) Español ภาษาไทย Türkçe українська Tiếng Việt

Odoo adalah rangkaian aplikasi bisnis open source yang mencakup semua kebutuhan perusahaan Anda: CRM, eCommerce, akuntansi, inventaris, point of sale, manajemen project, dan seterusnya.

Mudah digunakan dan terintegrasi penuh pada saat yang sama adalah value proposition unik Odoo.

Website made with

Odoo Experience on YouTube

1. Use the live chat to ask your questions.
2. The operator answers within a few minutes.

Live support on Youtube
Watch now