[FIX] event[_sms]: correctly take parameters from event type mail
PURPOSE
This commit 62ac23f0b9 introduced SMS capabilities on for
event.type.mail and event.mail models.
Values of event_type_mail_ids on event.type are supposed to be copied to
event_mail_ids on event.event when changing the event_type_id of an event.
There are however 2 issues with that integration:
- The 'notification_type' field was not correctly set on default
event_type_mail_ids on event.type;
- The 'notification_type' and 'sms_template' fields were not copied from
event_type_mail_ids to event_mail_ids;
LINKS
PR #39892
Task ID 2115792
closes odoo/odoo#41736
X-original-commit: 3fd66d844aa66ca8d54223071c787974e6c88c94
Signed-off-by: Thibault Delavallee (tde) <tde@openerp.com>
This commit is contained in:
@@ -27,15 +27,18 @@ class EventType(models.Model):
|
||||
@api.model
|
||||
def _get_default_event_type_mail_ids(self):
|
||||
return [(0, 0, {
|
||||
'notification_type': 'mail',
|
||||
'interval_unit': 'now',
|
||||
'interval_type': 'after_sub',
|
||||
'template_id': self.env.ref('event.event_subscription').id,
|
||||
}), (0, 0, {
|
||||
'notification_type': 'mail',
|
||||
'interval_nbr': 1,
|
||||
'interval_unit': 'days',
|
||||
'interval_type': 'before_event',
|
||||
'template_id': self.env.ref('event.event_reminder').id,
|
||||
}), (0, 0, {
|
||||
'notification_type': 'mail',
|
||||
'interval_nbr': 10,
|
||||
'interval_unit': 'days',
|
||||
'interval_type': 'before_event',
|
||||
@@ -270,11 +273,11 @@ class EventEvent(models.Model):
|
||||
self.is_online = self.event_type_id.is_online
|
||||
|
||||
if self.event_type_id.event_type_mail_ids:
|
||||
self.event_mail_ids = [(5, 0, 0)] + [(0, 0, {
|
||||
'template_id': line.template_id,
|
||||
'interval_nbr': line.interval_nbr,
|
||||
'interval_unit': line.interval_unit,
|
||||
'interval_type': line.interval_type})
|
||||
self.event_mail_ids = [(5, 0, 0)] + [
|
||||
(0, 0, {
|
||||
attribute_name: line[attribute_name]
|
||||
for attribute_name in self.env['event.type.mail']._get_event_mail_fields_whitelist()
|
||||
})
|
||||
for line in self.event_type_id.event_type_mail_ids]
|
||||
|
||||
@api.constrains('seats_min', 'seats_max', 'seats_availability')
|
||||
|
||||
@@ -46,6 +46,12 @@ class EventTypeMail(models.Model):
|
||||
domain=[('model', '=', 'event.registration')], ondelete='restrict',
|
||||
help='This field contains the template of the mail that will be automatically sent')
|
||||
|
||||
@api.model
|
||||
def _get_event_mail_fields_whitelist(self):
|
||||
""" Whitelist of fields that are copied from event_type_mail_ids to event_mail_ids when
|
||||
changing the event_type_id field of event.event """
|
||||
return ['notification_type', 'template_id', 'interval_nbr', 'interval_unit', 'interval_type']
|
||||
|
||||
|
||||
class EventMailScheduler(models.Model):
|
||||
""" Event automated mailing. This model replaces all existing fields and
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Part of Odoo. See LICENSE file for full copyright and licensing details.
|
||||
|
||||
from odoo import fields, models
|
||||
from odoo import api, fields, models
|
||||
|
||||
|
||||
class EventTypeMail(models.Model):
|
||||
@@ -13,6 +13,10 @@ class EventTypeMail(models.Model):
|
||||
domain=[('model', '=', 'event.registration')], ondelete='restrict',
|
||||
help='This field contains the template of the SMS that will be automatically sent')
|
||||
|
||||
@api.model
|
||||
def _get_event_mail_fields_whitelist(self):
|
||||
return super(EventTypeMail, self)._get_event_mail_fields_whitelist() + ['sms_template_id']
|
||||
|
||||
|
||||
class EventMailScheduler(models.Model):
|
||||
_inherit = 'event.mail'
|
||||
|
||||
Reference in New Issue
Block a user