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:
parent
39d8f46a8b
commit
9355c76eca
1 changed files with 12 additions and 3 deletions
|
|
@ -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
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue