[Fix] Use company_fieldname as parameter to the query
This commit is contained in:
parent
0f4cb55c3c
commit
c48eb45410
@ -38,7 +38,7 @@ def delete_for_doctype(doctype, company_name):
|
|||||||
if not meta.issingle:
|
if not meta.issingle:
|
||||||
if not meta.istable:
|
if not meta.istable:
|
||||||
# delete communication
|
# delete communication
|
||||||
delete_communications(meta, doctype, company_name)
|
delete_communications(doctype, company_name, company_fieldname)
|
||||||
|
|
||||||
# delete children
|
# delete children
|
||||||
for df in meta.get_table_fields():
|
for df in meta.get_table_fields():
|
||||||
@ -79,10 +79,8 @@ def delete_lead_addresses(company_name):
|
|||||||
|
|
||||||
frappe.db.sql("""update `tabAddress` set lead=null, lead_name=null where lead=%s""", lead.name)
|
frappe.db.sql("""update `tabAddress` set lead=null, lead_name=null where lead=%s""", lead.name)
|
||||||
|
|
||||||
def delete_communications(meta, doctype, company_name):
|
def delete_communications(doctype, company_name, company_fieldname):
|
||||||
linkfields = [df.fieldname for df in meta.get_link_fields()]
|
frappe.db.sql("""
|
||||||
|
DELETE FROM `tabCommunication` WHERE reference_doctype = %s AND
|
||||||
if 'company' in linkfields:
|
EXISTS (SELECT name FROM `tab{0}` WHERE {1} = %s AND `tabCommunication`.reference_name = name)
|
||||||
frappe.db.sql("""DELETE FROM `tabCommunication` WHERE reference_doctype = "{0}" AND
|
""".format(doctype, company_fieldname), (doctype, company_name))
|
||||||
EXISTS (SELECT name FROM `tab{1}` WHERE company = %s AND `tabCommunication`.reference_name = name)
|
|
||||||
""".format(doctype, doctype), company_name)
|
|
||||||
|
Loading…
Reference in New Issue
Block a user