fix: Display message to delete linked invoices in the draft state

This commit is contained in:
GangaManoj 2021-10-02 02:03:29 +05:30
parent ece446ffe5
commit 99edc9c83a

View File

@ -241,7 +241,7 @@ class SalesOrder(SellingController):
# Checks Sales Invoice
submit_rv = frappe.db.sql_list("""select t1.name
from `tabSales Invoice` t1,`tabSales Invoice Item` t2
where t1.name = t2.parent and t2.sales_order = %s and t1.docstatus < 2""",
where t1.name = t2.parent and t2.sales_order = %s and t1.docstatus = 1""",
self.name)
if submit_rv:
@ -249,6 +249,16 @@ class SalesOrder(SellingController):
frappe.throw(_("Sales Invoice {0} must be cancelled before cancelling this Sales Order")
.format(", ".join(submit_rv)))
draft_rv = frappe.db.sql_list("""select t1.name
from `tabSales Invoice` t1,`tabSales Invoice Item` t2
where t1.name = t2.parent and t2.sales_order = %s and t1.docstatus = 0""",
self.name)
if draft_rv:
draft_rv = [get_link_to_form("Sales Invoice", si) for si in draft_rv]
frappe.throw(_("Sales Invoice {0} must be deleted before cancelling this Sales Order")
.format(", ".join(draft_rv)))
#check maintenance schedule
submit_ms = frappe.db.sql_list("""
select t1.name