feat: deleting account & stock entries on deletion of transaction (#24298)

* feat: control for deleting account & stock entries on deletion of a transaction

* chore: change label & fieldname

Co-authored-by: Nabin Hait <nabinhait@gmail.com>
This commit is contained in:
Saqib
2021-01-28 12:26:45 +05:30
committed by GitHub
parent 3914aca647
commit 8e55677f10
2 changed files with 15 additions and 2 deletions

View File

@@ -118,6 +118,12 @@ class AccountsController(TransactionBase):
def before_cancel(self):
validate_einvoice_fields(self)
def on_trash(self):
# delete sl and gl entries on deletion of transaction
if frappe.db.get_single_value('Accounts Settings', 'delete_linked_ledger_entries'):
frappe.db.sql("delete from `tabGL Entry` where voucher_type=%s and voucher_no=%s", (self.doctype, self.name))
frappe.db.sql("delete from `tabStock Ledger Entry` where voucher_type=%s and voucher_no=%s", (self.doctype, self.name))
def validate_deferred_start_and_end_date(self):
for d in self.items: