fix: disable sales order cancellation if linked to draft invoice (#26125)

This commit is contained in:
Subin Tom 2021-06-22 16:28:58 +05:30 committed by GitHub
parent 889140fd8c
commit 219a87d530
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 1 deletions

View File

@ -233,7 +233,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 = 1""",
where t1.name = t2.parent and t2.sales_order = %s and t1.docstatus < 2""",
self.name)
if submit_rv:

View File

@ -1217,6 +1217,19 @@ class TestSalesOrder(unittest.TestCase):
# To test if the SO does NOT have a Blanket Order
self.assertEqual(so_doc.items[0].blanket_order, None)
def test_so_cancellation_when_si_drafted(self):
"""
Test to check if Sales Order gets cancelled if Sales Invoice is in Draft state
Expected result: sales order should not get cancelled
"""
so = make_sales_order()
so.submit()
si = make_sales_invoice(so.name)
si.save()
self.assertRaises(frappe.ValidationError, so.cancel)
def make_sales_order(**args):
so = frappe.new_doc("Sales Order")