mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-31 10:49:09 +00:00
[fix] delete lead addresses in delete company transaction
This commit is contained in:
@@ -17,8 +17,8 @@ def delete_company_transactions(company_name):
|
|||||||
frappe.throw(_("Transactions can only be deleted by the creator of the Company"), frappe.PermissionError)
|
frappe.throw(_("Transactions can only be deleted by the creator of the Company"), frappe.PermissionError)
|
||||||
|
|
||||||
delete_bins(company_name)
|
delete_bins(company_name)
|
||||||
|
|
||||||
delete_time_logs(company_name)
|
delete_time_logs(company_name)
|
||||||
|
delete_lead_addresses(company_name)
|
||||||
|
|
||||||
for doctype in frappe.db.sql_list("""select parent from
|
for doctype in frappe.db.sql_list("""select parent from
|
||||||
tabDocField where fieldtype='Link' and options='Company'"""):
|
tabDocField where fieldtype='Link' and options='Company'"""):
|
||||||
@@ -85,3 +85,10 @@ def delete_time_logs(company_name):
|
|||||||
and exists(select name from `tabSales Invoice`
|
and exists(select name from `tabSales Invoice`
|
||||||
where name=`tabTime Log`.sales_invoice and company=%(company)s))
|
where name=`tabTime Log`.sales_invoice and company=%(company)s))
|
||||||
""", {"company": company_name})
|
""", {"company": company_name})
|
||||||
|
|
||||||
|
def delete_lead_addresses(company_name):
|
||||||
|
"""Delete addresses to which leads are linked"""
|
||||||
|
frappe.db.sql("""delete from `tabAddress`
|
||||||
|
where (customer='' or customer is null) and (supplier='' or supplier is null) and (lead != '' and lead is not null)""")
|
||||||
|
|
||||||
|
frappe.db.sql("""update `tabAddress` set lead=null, lead_name=null""")
|
||||||
|
|||||||
Reference in New Issue
Block a user