[IMP] calendar, hr_holidays: uniformize context key to prevent sending mail to attendees
Code courtesy of tde-banana-odoo
This commit is contained in:
@@ -138,7 +138,7 @@ class Attendee(models.Model):
|
||||
|
||||
res = False
|
||||
|
||||
if self.env['ir.config_parameter'].get_param('calendar.block_mail', self._context.get("no_mail_to_attendees")):
|
||||
if self.env['ir.config_parameter'].get_param('calendar.block_mail') or self._context.get("no_mail_to_attendees"):
|
||||
return res
|
||||
|
||||
calendar_view = self.env.ref('calendar.view_calendar_event_calendar')
|
||||
@@ -509,7 +509,11 @@ class MeetingType(models.Model):
|
||||
|
||||
|
||||
class Meeting(models.Model):
|
||||
""" Model for Calendar Event """
|
||||
""" Model for Calendar Event
|
||||
|
||||
Special context keys :
|
||||
- `no_mail_to_attendees` : disabled sending email to attendees when creating/editing a meeting
|
||||
"""
|
||||
|
||||
_name = 'calendar.event'
|
||||
_description = "Event"
|
||||
@@ -914,8 +918,7 @@ class Meeting(models.Model):
|
||||
|
||||
if current_user.email != partner.email:
|
||||
mail_from = current_user.email or tools.config.get('email_from', False)
|
||||
if not self._context.get('no_email'):
|
||||
attendee._send_mail_to_attendees(email_from=mail_from)
|
||||
attendee._send_mail_to_attendees(email_from=mail_from)
|
||||
|
||||
if meeting_attendees:
|
||||
meeting.write({'attendee_ids': [(4, attendee.id) for attendee in meeting_attendees]})
|
||||
|
||||
@@ -441,7 +441,7 @@ class Holidays(models.Model):
|
||||
if holiday.user_id and holiday.user_id.partner_id:
|
||||
meeting_values['partner_ids'] = [(4, holiday.user_id.partner_id.id)]
|
||||
|
||||
meeting = self.env['calendar.event'].with_context(no_email=True).create(meeting_values)
|
||||
meeting = self.env['calendar.event'].with_context(no_mail_to_attendees=True).create(meeting_values)
|
||||
holiday._create_resource_leave()
|
||||
holiday.write({'meeting_id': meeting.id})
|
||||
elif holiday.holiday_type == 'category':
|
||||
|
||||
Reference in New Issue
Block a user