From 67e480705013037e5f1e5ad1d90cea5c6eb8648a Mon Sep 17 00:00:00 2001 From: shubham Date: Thu, 16 Jan 2025 15:54:34 +0530 Subject: [PATCH] test: add test case so for stock unreserve --- .../doctype/sales_order/test_sales_order.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/erpnext/selling/doctype/sales_order/test_sales_order.py b/erpnext/selling/doctype/sales_order/test_sales_order.py index 270644baed14..f5919b3dcfb0 100644 --- a/erpnext/selling/doctype/sales_order/test_sales_order.py +++ b/erpnext/selling/doctype/sales_order/test_sales_order.py @@ -4486,7 +4486,7 @@ def test_sales_order_creating_invoice_with_installation_note_and_gst_TC_S_062(se self.assertEqual(frappe.db.get_value('GL Entry', {'voucher_no': si.name, 'account': 'Output Tax SGST - _TIRC'}, 'credit'), 9) self.assertEqual(frappe.db.get_value('GL Entry', {'voucher_no': si.name, 'account': 'Output Tax CGST - _TIRC'}, 'credit'), 9) - def test_sales_order_for_stock_reservation_TC_S_063(self, reuse=None): + def test_sales_order_for_stock_reservation_TC_S_063(self, reuse=None, get_so_with_stock_reserved=None): make_stock_entry(item_code="_Test Item", qty=10, rate=5000, target="_Test Warehouse - _TC") stock_setting = frappe.get_doc('Stock Settings') @@ -4509,6 +4509,9 @@ def test_sales_order_for_stock_reservation_TC_S_063(self, reuse=None): self.assertEqual(frappe.db.get_value("Stock Reservation Entry", {"voucher_no": so.name}, "status"), "Reserved") + if get_so_with_stock_reserved: + return so + dn = make_delivery_note(so.name) dn.save() dn.submit() @@ -4756,6 +4759,15 @@ def test_sales_order_for_auto_stock_reservation_TC_S_070(self, reuse=None): self.assertEqual(frappe.db.get_value('GL Entry', {'voucher_no': pi.name, 'account': 'Creditors - _TC'}, 'credit'), 5000) self.assertEqual(frappe.db.get_value('GL Entry', {'voucher_no': pi.name, 'account': 'Cost of Goods Sold - _TC'}, 'debit'), 5000) + def test_sales_order_for_stock_unreserve_TC_S_071(self): + so = self.test_sales_order_for_stock_reservation_TC_S_063(get_so_with_stock_reserved=1) + + from erpnext.stock.doctype.stock_reservation_entry.stock_reservation_entry import cancel_stock_reservation_entries + + cancel_stock_reservation_entries(voucher_type="Sales Order", voucher_no=so.name, sre_list=None, notify=True) + + self.assertEqual(frappe.db.get_value("Stock Reservation Entry", {"voucher_no": so.name}, "status"), "Cancelled") + def create_and_submit_sales_order(self, qty=None, rate=None): sales_order = make_sales_order(cost_center='Main - _TC', selling_price_list='Standard Selling', do_not_save=True) sales_order.delivery_date = nowdate()