diff --git a/erpnext/patches/v6_2/fix_missing_default_taxes_and_lead.py b/erpnext/patches/v6_2/fix_missing_default_taxes_and_lead.py index 9c16f63798..b0cfc3d3bf 100644 --- a/erpnext/patches/v6_2/fix_missing_default_taxes_and_lead.py +++ b/erpnext/patches/v6_2/fix_missing_default_taxes_and_lead.py @@ -2,6 +2,11 @@ from __future__ import unicode_literals import frappe def execute(): + # remove missing lead + for customer in frappe.db.sql_list("""select name from `tabCustomer` + where ifnull(lead_name, '')!='' and not exists (select name from `tabLead` where name=`tabCustomer`.lead_name)"""): + frappe.db.set_value("Customer", customer, "lead_name", None) + # remove missing default taxes for customer in frappe.db.sql_list("""select name from `tabCustomer` where ifnull(default_taxes_and_charges, '')!='' and not exists ( @@ -18,8 +23,3 @@ def execute(): c = frappe.get_doc("Supplier", supplier) c.default_taxes_and_charges = None c.save() - - # remove missing lead - for customer in frappe.db.sql_list("""select name from `tabCustomer` - where ifnull(lead_name, '')!='' and not exists (select name from `tabLead` where name=`tabCustomer`.lead_name)"""): - frappe.db.set_value("Customer", customer, "lead_name", None)