fix: Validation for Suppliers in SO to PO (#19686)
- Check if there is a Supplier against atleast one item in Sales Order
- Validation message earlier was vague
diff --git a/erpnext/selling/doctype/sales_order/sales_order.py b/erpnext/selling/doctype/sales_order/sales_order.py
index e12b359..e97a4ee 100755
--- a/erpnext/selling/doctype/sales_order/sales_order.py
+++ b/erpnext/selling/doctype/sales_order/sales_order.py
@@ -834,6 +834,10 @@
for item in sales_order.items:
if item.supplier and item.supplier not in suppliers:
suppliers.append(item.supplier)
+
+ if not suppliers:
+ frappe.throw(_("Please set a Supplier against the Items to be considered in the Purchase Order."))
+
for supplier in suppliers:
po =frappe.get_list("Purchase Order", filters={"sales_order":source_name, "supplier":supplier, "docstatus": ("<", "2")})
if len(po) == 0: