mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-15 11:09:17 +00:00
Merge pull request #53811 from khushi8112/customer-group-is-group-validation
fix: prevent selection of group type customer group in customer master
This commit is contained in:
@@ -382,7 +382,7 @@ def add_vouchers(gl_account="_Test Bank - _TC"):
|
|||||||
frappe.get_doc(
|
frappe.get_doc(
|
||||||
{
|
{
|
||||||
"doctype": "Customer",
|
"doctype": "Customer",
|
||||||
"customer_group": "All Customer Groups",
|
"customer_group": "Individual",
|
||||||
"customer_type": "Company",
|
"customer_type": "Company",
|
||||||
"customer_name": "Poore Simon's",
|
"customer_name": "Poore Simon's",
|
||||||
}
|
}
|
||||||
@@ -413,7 +413,7 @@ def add_vouchers(gl_account="_Test Bank - _TC"):
|
|||||||
frappe.get_doc(
|
frappe.get_doc(
|
||||||
{
|
{
|
||||||
"doctype": "Customer",
|
"doctype": "Customer",
|
||||||
"customer_group": "All Customer Groups",
|
"customer_group": "Individual",
|
||||||
"customer_type": "Company",
|
"customer_type": "Company",
|
||||||
"customer_name": "Fayva",
|
"customer_name": "Fayva",
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -180,7 +180,7 @@ def make_customer(customer=None):
|
|||||||
{
|
{
|
||||||
"doctype": "Customer",
|
"doctype": "Customer",
|
||||||
"customer_name": customer_name,
|
"customer_name": customer_name,
|
||||||
"customer_group": "All Customer Groups",
|
"customer_group": "Individual",
|
||||||
"customer_type": "Company",
|
"customer_type": "Company",
|
||||||
"territory": "All Territories",
|
"territory": "All Territories",
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ class TestTaxes(ERPNextTestSuite):
|
|||||||
{
|
{
|
||||||
"doctype": "Customer",
|
"doctype": "Customer",
|
||||||
"customer_name": uuid4(),
|
"customer_name": uuid4(),
|
||||||
"customer_group": "All Customer Groups",
|
"customer_group": "Individual",
|
||||||
}
|
}
|
||||||
).insert()
|
).insert()
|
||||||
self.supplier = frappe.get_doc(
|
self.supplier = frappe.get_doc(
|
||||||
|
|||||||
@@ -174,6 +174,7 @@ class Customer(TransactionBase):
|
|||||||
def validate(self):
|
def validate(self):
|
||||||
self.flags.is_new_doc = self.is_new()
|
self.flags.is_new_doc = self.is_new()
|
||||||
self.flags.old_lead = self.lead_name
|
self.flags.old_lead = self.lead_name
|
||||||
|
self.validate_customer_group()
|
||||||
validate_party_accounts(self)
|
validate_party_accounts(self)
|
||||||
self.validate_credit_limit_on_change()
|
self.validate_credit_limit_on_change()
|
||||||
self.set_loyalty_program()
|
self.set_loyalty_program()
|
||||||
@@ -357,6 +358,17 @@ class Customer(TransactionBase):
|
|||||||
frappe.NameError,
|
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):
|
def validate_credit_limit_on_change(self):
|
||||||
if self.get("__islocal") or not self.credit_limits:
|
if self.get("__islocal") or not self.credit_limits:
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -177,7 +177,7 @@ def create_shipment_customer(customer_name):
|
|||||||
customer = frappe.new_doc("Customer")
|
customer = frappe.new_doc("Customer")
|
||||||
customer.customer_name = customer_name
|
customer.customer_name = customer_name
|
||||||
customer.customer_type = "Company"
|
customer.customer_type = "Company"
|
||||||
customer.customer_group = "All Customer Groups"
|
customer.customer_group = "Individual"
|
||||||
customer.territory = "All Territories"
|
customer.territory = "All Territories"
|
||||||
customer.insert()
|
customer.insert()
|
||||||
return customer
|
return customer
|
||||||
|
|||||||
Reference in New Issue
Block a user