[IMP] event_mail_attachment:

allow possibility to add several mail prefix
This commit is contained in:
clementthomas
2024-02-20 11:24:14 +01:00
parent 7498057ef2
commit a8467735f2

View File

@@ -21,14 +21,16 @@ class MailTemplate(models.Model):
if template.event_attachment_name_prefix: if template.event_attachment_name_prefix:
for res_id in template_res_ids: for res_id in template_res_ids:
event_registration = self.env['event.registration'].browse(res_id) event_registration = self.env['event.registration'].browse(res_id)
attachments = self.env['ir.attachment'].search([ attachments = self.env['ir.attachment']
for event_attachment_name_prefix in template.event_attachment_name_prefix.split(","):
attachments |= self.env['ir.attachment'].search([
('res_model','=','event.registration'), ('res_model','=','event.registration'),
('res_id','=',res_id), ('res_id','=',res_id),
('name','like',template.event_attachment_name_prefix)]) ('name','like',event_attachment_name_prefix)])
attachments |= self.env['ir.attachment'].search([ attachments |= self.env['ir.attachment'].search([
('res_model','=','event.event'), ('res_model','=','event.event'),
('res_id','=',event_registration.event_id.id), ('res_id','=',event_registration.event_id.id),
('name','like',template.event_attachment_name_prefix)]) ('name','like',event_attachment_name_prefix)])
attachments_res = [(attachment.name, attachment.datas) for attachment in attachments] attachments_res = [(attachment.name, attachment.datas) for attachment in attachments]