Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,26 @@
# For license information, please see license.txt

from __future__ import unicode_literals
# import frappe
import frappe
from frappe.model.document import Document

class ExpenseEntry(Document):
pass

def on_cancel(self):
# Find and cancel linked journal entries
je_list = frappe.get_all("Journal Entry",
filters={
"bill_no": self.name,
"docstatus": 1
})

for je in je_list:
journal_entry = frappe.get_doc("Journal Entry", je.name)
if journal_entry.docstatus == 1:
# Cancel journal entry
journal_entry.cancel()
frappe.msgprint(f"Journal Entry {journal_entry.name} has been cancelled.")

# Now delete the journal entry
frappe.delete_doc("Journal Entry", journal_entry.name, force=1)
frappe.msgprint(f"Journal Entry {journal_entry.name} has been deleted.")