From 0146ddcfc61721d856998645345eb77b5156ecb2 Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Tue, 12 Jun 2012 14:09:44 +0530 Subject: [PATCH] delete communication log for supplier and customer, on trash --- erpnext/buying/doctype/supplier/supplier.py | 6 ++++++ erpnext/selling/doctype/customer/customer.py | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/erpnext/buying/doctype/supplier/supplier.py b/erpnext/buying/doctype/supplier/supplier.py index db2df4f7fb..524e03d78e 100644 --- a/erpnext/buying/doctype/supplier/supplier.py +++ b/erpnext/buying/doctype/supplier/supplier.py @@ -158,9 +158,15 @@ class DocType: 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 80ac9142ef..bdc64877cf 100644 --- a/erpnext/selling/doctype/customer/customer.py +++ b/erpnext/selling/doctype/customer/customer.py @@ -235,10 +235,16 @@ class DocType: 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)