2020-08-24 19:16:35 +00:00
|
|
|
# Copyright (c) 2020, Frappe and Contributors
|
|
|
|
# License: GNU General Public License v3. See license.txt
|
|
|
|
|
|
|
|
from __future__ import unicode_literals
|
|
|
|
import frappe
|
|
|
|
|
|
|
|
def execute():
|
|
|
|
frappe.reload_doc("setup", "doctype", "Email Digest")
|
2020-08-31 11:24:16 +00:00
|
|
|
frappe.reload_doc("setup", "doctype", "Email Digest Recipient")
|
2020-08-24 19:16:35 +00:00
|
|
|
email_digests = frappe.db.get_list('Email Digest', fields=['name', 'recipient_list'])
|
|
|
|
for email_digest in email_digests:
|
|
|
|
if email_digest.recipient_list:
|
|
|
|
for recipient in email_digest.recipient_list.split("\n"):
|
|
|
|
doc = frappe.get_doc({
|
|
|
|
'doctype': 'Email Digest Recipient',
|
|
|
|
'parenttype': 'Email Digest',
|
|
|
|
'parentfield': 'recipients',
|
|
|
|
'parent': email_digest.name,
|
|
|
|
'recipient': recipient
|
|
|
|
})
|
|
|
|
doc.insert()
|