Skip to content

Commit

Permalink
[ADD] tg_event: set default email template for the emails to be sent …
Browse files Browse the repository at this point in the history
…manually to the attendees using Send By Email button
  • Loading branch information
ilmir-k committed Dec 25, 2024
1 parent 4028039 commit 33b8e4c
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 0 deletions.
1 change: 1 addition & 0 deletions tg_event/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
=======
Expand Down
4 changes: 4 additions & 0 deletions tg_event/models/event_event.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
17 changes: 17 additions & 0 deletions tg_event/models/event_registration.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
3 changes: 3 additions & 0 deletions tg_event/views/event_views.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
<xpath expr="//field[@name='auto_confirm']" position="after">
<field name="subscribe_in_registrations" widget="many2many_tags" />
</xpath>
<xpath expr="//field[@name='tag_ids']" position="after">
<field name="default_email_template_id" />
</xpath>
</field>
</record>
</odoo>

0 comments on commit 33b8e4c

Please sign in to comment.