Send daily work summary alert to only enabled users (#14175)
* Send daily work summary alert to only enabled users * Fix import
This commit is contained in:
parent
26eb513274
commit
e03937fd6a
@ -105,10 +105,13 @@ class DailyWorkSummary(Document):
|
||||
|
||||
|
||||
def get_user_emails_from_group(group):
|
||||
'''Returns list of email of users from the given group
|
||||
'''Returns list of email of enabled users from the given group
|
||||
|
||||
:param group: Daily Work Summary Group `name`'''
|
||||
group_doc = frappe.get_doc('Daily Work Summary Group', group)
|
||||
emails = [d.email for d in group_doc.users]
|
||||
group_doc = group
|
||||
if isinstance(group_doc, str):
|
||||
group_doc = frappe.get_doc('Daily Work Summary Group', group)
|
||||
|
||||
emails = [d.email for d in group_doc.users if frappe.db.get_value("User", d.email, "enabled")]
|
||||
|
||||
return emails
|
||||
|
@ -7,7 +7,7 @@ import frappe
|
||||
from frappe.model.document import Document
|
||||
import frappe.utils
|
||||
from frappe import _
|
||||
|
||||
from erpnext.hr.doctype.daily_work_summary.daily_work_summary import get_user_emails_from_group
|
||||
|
||||
class DailyWorkSummaryGroup(Document):
|
||||
def validate(self):
|
||||
@ -25,7 +25,7 @@ def trigger_emails():
|
||||
if (is_current_hour(group_doc.send_emails_at)
|
||||
and not is_holiday_today(group_doc.holiday_list)
|
||||
and group_doc.enabled):
|
||||
emails = [d.email for d in group_doc.users]
|
||||
emails = get_user_emails_from_group(group_doc)
|
||||
# find emails relating to a company
|
||||
if emails:
|
||||
daily_work_summary = frappe.get_doc(
|
||||
|
Loading…
x
Reference in New Issue
Block a user