def delete_lead_addresses(company_name):
 for lead in frappe.get_all(u'Lead', filters={u'company': company_name}):
  frappe.db.sql(u"delete from `tabAddress`\n DCTB  DCTB  DCTB where lead=%s and (customer='' or customer is null) and (supplier='' or supplier is null)", lead.name)
  frappe.db.sql(u'update `tabAddress` set lead=null, lead_name=null where lead=%s', lead.name)

def delete_lead_addresses ( company_name ) : for lead in frappe . get_all ( u'Lead' , filters = { u'company' : company_name } ) : frappe . db . sql ( u"delete from `tabAddress`\n DCTB  DCTB  DCTB where lead=%s and (customer='' or customer is null) and (supplier='' or supplier is null)" , lead . name ) frappe . db . sql ( u'update `tabAddress` set lead=null, lead_name=null where lead=%s' , lead . name )
delete addresses to which leads are linked .