Přejít na obsah
Menu
You need to be registered to interact with the community.
This question has been flagged

Where is the code for sending the following email notification from Odoo CRM located? I want to make changes to its content.

Odoo v18 Community Edition

Avatar
Zrušit
Nejlepší odpověď
Root of the Notification
  • This kind of notification does not use a QWeb or standard email template .
  • It is a system-generated notification based on a mail.activity being assigned.
  • Specifically, when an activity is scheduled/assigned (like lead assignment), Odoo internally uses mail.activity logic , and the notification is rendered in Python code .

Where to Find the Code
  1. Python Source File:
    File:
    odoo/addons/mail/models/mail_activity.py
    
  2. Relevant Method:
    def _notify_get_message_body(self, ...):
    
    This method dynamically generates the email/message content for the activity.
  3. Trigger Mechanism:
    When a new lead is created and assigned to a salesperson, the system triggers a mail.activity for that user with activity_type_id .

Why You Can't Find activity_data_lead_assigned
  • That ID ( activity_data_lead_assigned ) does not exist in standard records.
  • Lead assignment messages are not controlled via templated XML or records , but via backend logic (as above).
How to Customize the Notification (Options)
Option 1: Override the method

Create a custom module and override _notify_get_message_body in mail.activity .

Example:

from odoo.addons.mail.models.mail_activity import MailActivity

class CustomMailActivity(MailActivity):
    def _notify_get_message_body(self, **kwargs):
        body = super()._notify_get_message_body(**kwargs)
        # Add your custom message or modify the content
        if self.res_model == 'crm.lead':
            body = "<p>You have a new lead assigned: %s</p>" % (self.res_id)
        return body
Option 2: Use Server Actions or Automated Actions
  • Trigger on lead assignment or activity creation.
  • Send custom email using your own Email Template .
  • Go to: Settings > Technical > Automation > Automated Actions .

Suggested Path for Lead Assignment Notification Customization
  1. Create a custom email template .
  2. Use an Automated Action :
    • Model: CRM Lead
    • Trigger: On Update
    • Condition: user_id is changed.
    • Action: Send Email , using your custom template.

Final Notes
  • The mail.notification object simply transmits the message (email or chatter), but does not generate the text. That comes from mail.activity .
  • You won't find this message under “Email Templates,” because Odoo generates it dynamically.


Thanks & Regards,

Email: contact@datainteger.com

Avatar
Zrušit
Autor

1. There is no record with id activity_data_lead_assigned
2. This seems to be related to mail.notification, not mail.activity
3. This template is not present in Email Templates.

Related Posts Odpovědi Zobrazení Aktivita
1
čvn 25
836
2
čvn 25
549
3
čvc 25
915
2
zář 20
5027
2
bře 15
7132