diff --git a/stock/doctype/bin/bin.py b/stock/doctype/bin/bin.py index d8bc3830baa..8d21a5c83b7 100644 --- a/stock/doctype/bin/bin.py +++ b/stock/doctype/bin/bin.py @@ -355,12 +355,12 @@ class DocType: """ Notify user about auto creation of indent""" from webnotes.utils.email_lib import sendmail - email_list=[d[0] for d in sql("""select parent from tabUserRole - where role in ('Purchase Manager','Material Manager') - and parent not in ('Administrator', 'All', 'Guest')""")] + email_list=[d[0] for d in sql("""select distinct r.parent from tabUserRole r, tabProfile p + where p.name = r.parent and p.enabled = 1 and p.docstatus < 2 + and r.role in ('Purchase Manager','Material Manager') + and p.name not in ('Administrator', 'All', 'Guest')""")] msg="""A Purchase Request has been raised for item %s: %s on %s """ % (doc_type, doc_name, nowdate()) - sendmail(email_list, subject='Auto Purchase Request Generation Notification', msg = msg) def validate(self):