delete customer account on deletion of customer record
This commit is contained in:
parent
4ce8e16ded
commit
318eab813c
@ -169,6 +169,13 @@ class DocType:
|
|||||||
get_obj('Account', self.doc.parent_account).update_balance(fy, period_det, flag)
|
get_obj('Account', self.doc.parent_account).update_balance(fy, period_det, flag)
|
||||||
msgprint('Balances updated')
|
msgprint('Balances updated')
|
||||||
|
|
||||||
|
def validate_mandatory(self):
|
||||||
|
if not self.doc.debit_or_credit:
|
||||||
|
msgprint("Debit or Credit field is mandatory", raise_exception=1)
|
||||||
|
if not self.doc.is_pl_account:
|
||||||
|
msgprint("Is PL Account field is mandatory", raise_exception=1)
|
||||||
|
|
||||||
|
|
||||||
# VALIDATE
|
# VALIDATE
|
||||||
# ==================================================================
|
# ==================================================================
|
||||||
def validate(self):
|
def validate(self):
|
||||||
@ -177,6 +184,7 @@ class DocType:
|
|||||||
self.validate_parent()
|
self.validate_parent()
|
||||||
self.validate_duplicate_account()
|
self.validate_duplicate_account()
|
||||||
self.validate_root_details()
|
self.validate_root_details()
|
||||||
|
self.validate_mandatory()
|
||||||
|
|
||||||
# Defaults
|
# Defaults
|
||||||
if not self.doc.parent_account:
|
if not self.doc.parent_account:
|
||||||
|
|||||||
@ -239,12 +239,20 @@ class DocType:
|
|||||||
webnotes.conn.sql("""\
|
webnotes.conn.sql("""\
|
||||||
delete from `tabCommunication`
|
delete from `tabCommunication`
|
||||||
where customer = %s and supplier is null""", self.doc.name)
|
where customer = %s and supplier is null""", self.doc.name)
|
||||||
|
|
||||||
# ******************************************************* on trash *********************************************************
|
def delete_customer_account(self):
|
||||||
|
"""delete customer's ledger if exist and check balance before deletion"""
|
||||||
|
acc = sql("select name from `tabAccount` where master_type = 'Customer' \
|
||||||
|
and master_name = %s and docstatus < 2", self.doc.name)
|
||||||
|
if acc:
|
||||||
|
from webnotes.model import delete_doc
|
||||||
|
delete_doc('Account', acc[0][0])
|
||||||
|
|
||||||
def on_trash(self):
|
def on_trash(self):
|
||||||
self.delete_customer_address()
|
self.delete_customer_address()
|
||||||
self.delete_customer_contact()
|
self.delete_customer_contact()
|
||||||
self.delete_customer_communication()
|
self.delete_customer_communication()
|
||||||
|
self.delete_customer_account()
|
||||||
if self.doc.lead_name:
|
if self.doc.lead_name:
|
||||||
sql("update `tabLead` set status='Interested' where name=%s",self.doc.lead_name)
|
sql("update `tabLead` set status='Interested' where name=%s",self.doc.lead_name)
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user