only send to orderpositions included in op_qs

This commit is contained in:
Lukas Bockstaller
2026-07-03 12:14:39 +02:00
parent 2fb9711002
commit 696c1550f6
+26 -23
View File
@@ -162,6 +162,8 @@ class ScheduledMail(models.Model):
send_to_orders = self.rule.send_to in (Rule.CUSTOMERS, Rule.BOTH) send_to_orders = self.rule.send_to in (Rule.CUSTOMERS, Rule.BOTH)
send_to_attendees = self.rule.send_to in (Rule.ATTENDEES, Rule.BOTH) send_to_attendees = self.rule.send_to in (Rule.ATTENDEES, Rule.BOTH)
position_ids = op_qs.values_list('id', flat=True)
for o in orders: for o in orders:
with language(o.locale, e.settings.region): with language(o.locale, e.settings.region):
positions = list(o.positions.all()) positions = list(o.positions.all())
@@ -191,28 +193,29 @@ class ScheduledMail(models.Model):
positions = [p for p in positions if p.subevent_id == self.subevent_id] positions = [p for p in positions if p.subevent_id == self.subevent_id]
for p in positions: for p in positions:
if p.attendee_email and (p.attendee_email != o.email or not o_sent): if p.id in position_ids:
email_ctx = get_email_context( if p.attendee_email and (p.attendee_email != o.email or not o_sent):
event=e, email_ctx = get_email_context(
order=o, event=e,
invoice_address=ia, order=o,
position=p, invoice_address=ia,
event_or_subevent=self.subevent or e, position=p,
) event_or_subevent=self.subevent or e,
p.send_mail(self.rule.subject, self.rule.template, email_ctx, )
attach_ical=self.rule.attach_ical, p.send_mail(self.rule.subject, self.rule.template, email_ctx,
log_entry_type='pretix.plugins.sendmail.rule.order.position.email.sent') attach_ical=self.rule.attach_ical,
elif not o_sent and o.email: log_entry_type='pretix.plugins.sendmail.rule.order.position.email.sent')
email_ctx = get_email_context( elif not o_sent and o.email:
event=e, email_ctx = get_email_context(
order=o, event=e,
invoice_address=ia, order=o,
event_or_subevent=self.subevent or e, invoice_address=ia,
) event_or_subevent=self.subevent or e,
o.send_mail(self.rule.subject, self.rule.template, email_ctx, )
attach_ical=self.rule.attach_ical, o.send_mail(self.rule.subject, self.rule.template, email_ctx,
log_entry_type='pretix.plugins.sendmail.rule.order.email.sent') attach_ical=self.rule.attach_ical,
o_sent = True log_entry_type='pretix.plugins.sendmail.rule.order.email.sent')
o_sent = True
self.last_successful_order_id = o.pk self.last_successful_order_id = o.pk
@@ -270,7 +273,7 @@ class Rule(models.Model, LoggingMixin):
date_is_absolute = models.BooleanField(default=True, blank=True) date_is_absolute = models.BooleanField(default=True, blank=True)
offset_to_event_end = models.BooleanField(default=False, blank=True) # no verbose name because not actually offset_to_event_end = models.BooleanField(default=False, blank=True) # no verbose name because not actually
offset_is_after = models.BooleanField(default=False, blank=True) # displayed in any forms offset_is_after = models.BooleanField(default=False, blank=True) # displayed in any forms
send_to = models.CharField(max_length=10, choices=SEND_TO_CHOICES, default=CUSTOMERS, verbose_name=_('Send email to')) send_to = models.CharField(max_length=10, choices=SEND_TO_CHOICES, default=CUSTOMERS, verbose_name=_('Send email to'))