From 33b8e4c79bee0e162a7f6eabedfd2313171be02c Mon Sep 17 00:00:00 2001 From: Ilmir Karamov Date: Wed, 25 Dec 2024 18:23:33 +0500 Subject: [PATCH] [ADD] tg_event: set default email template for the emails to be sent manually to the attendees using Send By Email button --- tg_event/README.rst | 1 + tg_event/models/event_event.py | 4 ++++ tg_event/models/event_registration.py | 17 +++++++++++++++++ tg_event/views/event_views.xml | 3 +++ 4 files changed, 25 insertions(+) diff --git a/tg_event/README.rst b/tg_event/README.rst index 27e5788..42eb301 100644 --- a/tg_event/README.rst +++ b/tg_event/README.rst @@ -3,6 +3,7 @@ ======================================================== * In event form the field "Subscribe In Registrations" is added to set the partners for subscribing in event registration records +* Set email template taken from the related Event as default upon manual email sending to attendee in event registration form Credits ======= diff --git a/tg_event/models/event_event.py b/tg_event/models/event_event.py index 9b6c03a..06abb7e 100644 --- a/tg_event/models/event_event.py +++ b/tg_event/models/event_event.py @@ -7,3 +7,7 @@ class EventEvent(models.Model): subscribe_in_registrations = fields.Many2many( "res.partner", "event_reg_sub_partner" ) + default_email_template_id = fields.Many2one( + "mail.template", help="Default email template used upon manual sending the emails to attendees using " + "Send By Email button in the event registration form" + ) diff --git a/tg_event/models/event_registration.py b/tg_event/models/event_registration.py index 6a0a1fe..5aa7b0a 100644 --- a/tg_event/models/event_registration.py +++ b/tg_event/models/event_registration.py @@ -10,3 +10,20 @@ def create(self, vals_list): for record in records: record.message_subscribe(record.event_id.subscribe_in_registrations.ids) return records + + # Set email template taken from the related Event as default upon manual email sending to attendee + # in event registration form + def action_send_badge_email(self): + res = super(EventRegistration, self).action_send_badge_email() + default_tmpl = self.event_id.default_email_template_id + template = self.env['mail.template'].search([('id', '=', default_tmpl.id)]) + ctx = dict( + default_model='event.registration', + default_res_id=self.id, + default_use_template=bool(template), + default_template_id=template.id, + default_composition_mode='comment', + custom_layout="mail.mail_notification_light", + ) + res.update({'context': ctx}) + return res diff --git a/tg_event/views/event_views.xml b/tg_event/views/event_views.xml index 5621732..8e92c3f 100644 --- a/tg_event/views/event_views.xml +++ b/tg_event/views/event_views.xml @@ -8,6 +8,9 @@ + + +