fix: code improvement, match error type for message

This commit is contained in:
Abhishek Balam
2020-11-04 23:42:08 +05:30
parent 5fe3abcfae
commit 5db99e0649
2 changed files with 5 additions and 7 deletions

View File

@@ -92,7 +92,7 @@ frappe.ui.form.on('Process Statement Of Accounts', {
frm.refresh_field('customers'); frm.refresh_field('customers');
} }
else{ else{
frappe.msgprint('No Customers found with selected options.'); frappe.throw('No Customers found with selected options.');
} }
} }
} }

View File

@@ -126,13 +126,11 @@ def get_customers_based_on_sales_person(sales_person):
sales_person_records = frappe._dict() sales_person_records = frappe._dict()
for d in records: for d in records:
sales_person_records.setdefault(d.parenttype, set()).add(d.parent) sales_person_records.setdefault(d.parenttype, set()).add(d.parent)
if sales_person_records.get('Customer'):
try: return frappe.get_list('Customer', fields=['name', 'email_id'], \
customers = frappe.get_list('Customer', fields=['name', 'email_id'], \
filters=[['name', 'in', list(sales_person_records['Customer'])]]) filters=[['name', 'in', list(sales_person_records['Customer'])]])
except: else:
customers = [] return []
return customers
def get_recipients_and_cc(customer, doc): def get_recipients_and_cc(customer, doc):
recipients = [] recipients = []