delete communication log for supplier and customer, on trash
diff --git a/erpnext/buying/doctype/supplier/supplier.py b/erpnext/buying/doctype/supplier/supplier.py
index db2df4f..524e03d 100644
--- a/erpnext/buying/doctype/supplier/supplier.py
+++ b/erpnext/buying/doctype/supplier/supplier.py
@@ -158,9 +158,15 @@
for rec in sql("select * from `tabContact` where supplier='%s'" %(self.doc.name), as_dict=1):
sql("delete from `tabContact` where name=%s",(rec['name']))
+ def delete_supplier_communication(self):
+ webnotes.conn.sql("""\
+ delete from `tabCommunication`
+ where supplier = %s and customer is null""", self.doc.name)
+
def on_trash(self):
self.delete_supplier_address()
self.delete_supplier_contact()
+ self.delete_supplier_communication()
# on rename
# ---------
diff --git a/erpnext/selling/doctype/customer/customer.py b/erpnext/selling/doctype/customer/customer.py
index 80ac914..bdc6487 100644
--- a/erpnext/selling/doctype/customer/customer.py
+++ b/erpnext/selling/doctype/customer/customer.py
@@ -235,10 +235,16 @@
for rec in sql("select * from `tabContact` where customer='%s'" %(self.doc.name), as_dict=1):
sql("delete from `tabContact` where name=%s",(rec['name']))
+ def delete_customer_communication(self):
+ webnotes.conn.sql("""\
+ delete from `tabCommunication`
+ where customer = %s and supplier is null""", self.doc.name)
+
# ******************************************************* on trash *********************************************************
def on_trash(self):
self.delete_customer_address()
self.delete_customer_contact()
+ self.delete_customer_communication()
if self.doc.lead_name:
sql("update `tabLead` set status='Interested' where name=%s",self.doc.lead_name)