fix: prevent selection of group type customer group in customer master

(cherry picked from commit 6068dc959f)
This commit is contained in:
khushi8112
2026-03-26 16:23:14 +05:30
committed by Mergify
parent e159c79766
commit 9ab5ee252a

View File

@@ -145,6 +145,7 @@ class Customer(TransactionBase):
def validate(self):
self.flags.is_new_doc = self.is_new()
self.flags.old_lead = self.lead_name
self.validate_customer_group()
validate_party_accounts(self)
self.validate_credit_limit_on_change()
self.set_loyalty_program()
@@ -324,6 +325,17 @@ class Customer(TransactionBase):
frappe.NameError,
)
def validate_customer_group(self):
if not self.customer_group:
return
is_group = frappe.db.get_value("Customer Group", self.customer_group, "is_group")
if is_group:
frappe.throw(
_("Cannot select a Group type Customer Group. Please select a non-group Customer Group."),
title=_("Invalid Customer Group"),
)
def validate_credit_limit_on_change(self):
if self.get("__islocal") or not self.credit_limits:
return