From 4bcea5556337e9dc5ccaa4d8fc55bb7e54fe1d81 Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Fri, 25 Apr 2025 11:33:04 +0530 Subject: [PATCH] fix: prohibit consolidated sales invoice return (backport #47251) (#47252) fix: prohibit consolidated sales invoice return (#47251) (cherry picked from commit 483c4a327169b58464c22038a308c35637cb0ed5) Co-authored-by: Diptanil Saha --- erpnext/controllers/sales_and_purchase_return.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/erpnext/controllers/sales_and_purchase_return.py b/erpnext/controllers/sales_and_purchase_return.py index 74c5e34ecfa..d5aa7823751 100644 --- a/erpnext/controllers/sales_and_purchase_return.py +++ b/erpnext/controllers/sales_and_purchase_return.py @@ -347,6 +347,16 @@ def make_return_doc(doctype: str, source_name: str, target_doc=None, return_agai "Company", company, "default_warehouse_for_sales_return" ) + if doctype == "Sales Invoice": + inv_is_consolidated, inv_is_pos = frappe.db.get_value( + "Sales Invoice", source_name, ["is_consolidated", "is_pos"] + ) + if inv_is_consolidated and inv_is_pos: + frappe.throw( + _("Cannot create return for consolidated invoice {0}.").format(source_name), + title=_("Cannot Create Return"), + ) + def set_missing_values(source, target): doc = frappe.get_doc(target) doc.is_return = 1