[fix] Get email field if field type is Code, Text, Small Text or Data
This commit is contained in:
parent
91a58808c0
commit
33f42aaad1
@ -13,12 +13,14 @@ class NewsletterList(Document):
|
|||||||
def onload(self):
|
def onload(self):
|
||||||
singles = [d.name for d in frappe.db.get_all("DocType", "name", {"issingle": 1})]
|
singles = [d.name for d in frappe.db.get_all("DocType", "name", {"issingle": 1})]
|
||||||
self.get("__onload").import_types = [{"value": d.parent, "label": "{0} ({1})".format(d.parent, d.label)} \
|
self.get("__onload").import_types = [{"value": d.parent, "label": "{0} ({1})".format(d.parent, d.label)} \
|
||||||
for d in frappe.db.get_all("DocField", ("parent", "label"), {"options": "Email"}) if d.parent not in singles]
|
for d in frappe.db.get_all("DocField", ("parent", "label"), {"options": "Email"})
|
||||||
|
if d.parent not in singles]
|
||||||
|
|
||||||
def import_from(self, doctype):
|
def import_from(self, doctype):
|
||||||
"""Extract email ids from given doctype and add them to the current list"""
|
"""Extract email ids from given doctype and add them to the current list"""
|
||||||
meta = frappe.get_meta(doctype)
|
meta = frappe.get_meta(doctype)
|
||||||
email_field = [d.fieldname for d in meta.fields if d.fieldtype in ("Data", "Small Text") and d.options=="Email"][0]
|
email_field = [d.fieldname for d in meta.fields
|
||||||
|
if d.fieldtype in ("Data", "Small Text", "Text", "Code") and d.options=="Email"][0]
|
||||||
unsubscribed_field = "unsubscribed" if meta.get_field("unsubscribed") else None
|
unsubscribed_field = "unsubscribed" if meta.get_field("unsubscribed") else None
|
||||||
added = 0
|
added = 0
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user