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>
This commit is contained in:
mergify[bot] 2023-08-26 19:29:33 +05:30 committed by GitHub
parent fa2e5d5ab7
commit 35f72a17db
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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
)