customer/supplier address deletion fix
diff --git a/crm/doctype/customer/customer.py b/crm/doctype/customer/customer.py
index 3d2fa59..eba2fc0 100644
--- a/crm/doctype/customer/customer.py
+++ b/crm/doctype/customer/customer.py
@@ -214,8 +214,17 @@
#create address and contact from lead
self.create_lead_address_contact()
+ def delete_customer_address(self):
+ for rec in sql("select * from `tabAddress` where customer='%s'" %(self.doc.name), as_dict=1):
+ sql("delete from `tabAddress` where name=%s",(rec['name']))
+
+ def delete_customer_contact(self):
+ 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']))
# ******************************************************* on trash *********************************************************
- def on_trash(self):
+ def on_trash(self):
+ self.delete_customer_address()
+ self.delete_customer_contact()
if self.doc.lead_name:
sql("update `tabLead` set status='Interested' where name=%s",self.doc.lead_name)
diff --git a/srm/doctype/supplier/supplier.py b/srm/doctype/supplier/supplier.py
index e6db6c3..31d5b3d 100644
--- a/srm/doctype/supplier/supplier.py
+++ b/srm/doctype/supplier/supplier.py
@@ -134,3 +134,15 @@
return contact_details
else:
return ''
+
+ def delete_supplier_address(self):
+ for rec in sql("select * from `tabAddress` where supplier='%s'" %(self.doc.name), as_dict=1):
+ sql("delete from `tabAddress` where name=%s",(rec['name']))
+
+ def delete_supplier_contact(self):
+ 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 on_trash(self):
+ self.delete_supplier_address()
+ self.delete_supplier_contact()