From 35f72a17db1455a7c1ac082025b6d2ae9fdfe36a Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Sat, 26 Aug 2023 19:29:33 +0530 Subject: [PATCH] Allow to make return against sales invoice which has closed sales order. (#36676) fix: Allow to make return against sales invoice which has closed sales order fix: Allow to make return against sales invoice which has closed sales order (cherry picked from commit 0f98cc85e9dce00fa333474cfb438f243503df81) Co-authored-by: Gourav Saini <63018500+gouravsaini021@users.noreply.github.com> --- erpnext/controllers/selling_controller.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/erpnext/controllers/selling_controller.py b/erpnext/controllers/selling_controller.py index 6f1a50dab1..9771f60ceb 100644 --- a/erpnext/controllers/selling_controller.py +++ b/erpnext/controllers/selling_controller.py @@ -388,7 +388,7 @@ class SellingController(StockController): for d in self.get("items"): if d.get(ref_fieldname): status = frappe.db.get_value("Sales Order", d.get(ref_fieldname), "status") - if status in ("Closed", "On Hold"): + if status in ("Closed", "On Hold") and not self.is_return: frappe.throw(_("Sales Order {0} is {1}").format(d.get(ref_fieldname), status)) def update_reserved_qty(self): @@ -404,7 +404,9 @@ class SellingController(StockController): if so and so_item_rows: sales_order = frappe.get_doc("Sales Order", so) - if sales_order.status in ["Closed", "Cancelled"]: + if (sales_order.status == "Closed" and not self.is_return) or sales_order.status in [ + "Cancelled" + ]: frappe.throw( _("{0} {1} is cancelled or closed").format(_("Sales Order"), so), frappe.InvalidStatusError )