fix: disable sales order cancellation if linked to draft invoice (#26125)
This commit is contained in:
parent
889140fd8c
commit
219a87d530
@ -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:
|
||||
|
@ -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")
|
||||
|
Loading…
x
Reference in New Issue
Block a user