fix(email_group): prevent StopIteration when running import on a doctype without email fields (#33418)

Signed-off-by: Akhil Narang <me@akhilnarang.dev>
This commit is contained in:
Akhil Narang 2025-07-31 13:50:15 +05:30 committed by GitHub
parent 39d8f46a8b
commit 9355c76eca
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -38,10 +38,19 @@ class EmailGroup(Document):
"""Extract Email Addresses from given doctype and add them to the current list"""
meta = frappe.get_meta(doctype)
email_field = next(
d.fieldname
for d in meta.fields
if d.fieldtype in ("Data", "Small Text", "Text", "Code") and d.options == "Email"
(
d.fieldname
for d in meta.fields
if d.fieldtype in ("Data", "Small Text", "Text", "Code") and d.options == "Email"
),
None,
)
if not email_field:
frappe.throw(
_("No Email field found in {0}").format(doctype),
title=_("Invalid Doctype"),
)
unsubscribed_field = "unsubscribed" if meta.get_field("unsubscribed") else None
added = 0