[Fix] Not able to delete customer if contact is available
This commit is contained in:
parent
402ffa8b29
commit
52a692ee08
@ -173,6 +173,11 @@ class Customer(TransactionBase):
|
||||
frappe.throw(_("""New credit limit is less than current outstanding amount for the customer. Credit limit has to be atleast {0}""").format(outstanding_amt))
|
||||
|
||||
def on_trash(self):
|
||||
if self.customer_primary_contact:
|
||||
frappe.db.sql("""update `tabCustomer`
|
||||
set customer_primary_contact=null, mobile_no=null, email_id=null
|
||||
where name=%s""", self.name)
|
||||
|
||||
delete_contact_and_address('Customer', self.name)
|
||||
if self.lead_name:
|
||||
frappe.db.sql("update `tabLead` set status='Interested' where name=%s", self.lead_name)
|
||||
|
@ -96,6 +96,15 @@ class TestCustomer(unittest.TestCase):
|
||||
|
||||
so.save()
|
||||
|
||||
def test_delete_customer_contact(self):
|
||||
customer = frappe.get_doc(
|
||||
get_customer_dict('_Test Customer for delete')).insert(ignore_permissions=True)
|
||||
|
||||
customer.mobile_no = "8989889890"
|
||||
customer.save()
|
||||
self.assertTrue(customer.customer_primary_contact)
|
||||
frappe.delete_doc('Customer', customer.name)
|
||||
|
||||
def test_disabled_customer(self):
|
||||
make_test_records("Item")
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user