gl_list = frappe.get_all("GL Entry", {"voucher_no": self.journal_entry})
if gl_list:
for i in gl_list:
gl = frappe.get_doc("GL Entry", i.name)
if gl.docstatus == 1:
gl.cancel()
je = frappe.get_doc("Journal Entry", self.journal_entry)
if je.docstatus == 1:
je.cancel()