feat: details fetched from customer group in customer
diff --git a/erpnext/selling/doctype/customer/customer.js b/erpnext/selling/doctype/customer/customer.js
index 825b170..91944ad 100644
--- a/erpnext/selling/doctype/customer/customer.js
+++ b/erpnext/selling/doctype/customer/customer.js
@@ -130,6 +130,10 @@
erpnext.utils.make_pricing_rule(frm.doc.doctype, frm.doc.name);
}, __('Create'));
+ frm.add_custom_button(__('Get Customer Group Details'), function () {
+ frm.trigger("get_customer_group_details");
+ }, __('Actions'));
+
// indicator
erpnext.utils.set_party_dashboard_indicators(frm);
@@ -145,4 +149,15 @@
if(frm.doc.lead_name) frappe.model.clear_doc("Lead", frm.doc.lead_name);
},
-});
\ No newline at end of file
+ get_customer_group_details: function(frm) {
+ frappe.call({
+ method: "get_customer_group_details",
+ doc: frm.doc,
+ callback: function(r){
+ frm.refresh()
+ }
+ });
+
+ }
+});
+
diff --git a/erpnext/selling/doctype/customer/customer.py b/erpnext/selling/doctype/customer/customer.py
index 818888c..cdeb089 100644
--- a/erpnext/selling/doctype/customer/customer.py
+++ b/erpnext/selling/doctype/customer/customer.py
@@ -78,6 +78,32 @@
if sum(member.allocated_percentage or 0 for member in self.sales_team) != 100:
frappe.throw(_("Total contribution percentage should be equal to 100"))
+ @frappe.whitelist()
+ def get_customer_group_details(self):
+ doc = frappe.get_doc('Customer Group', self.customer_group)
+ self.accounts = self.credit_limits = []
+ self.payment_terms = self.default_price_list = ""
+
+ if not self.accounts and doc.accounts:
+ for account in doc.accounts:
+ child = self.append('accounts')
+ child.company = account.company
+ child.account = account.account
+ self.save()
+
+ if not self.credit_limits and doc.credit_limits:
+ for credit in doc.credit_limits:
+ child = self.append('credit_limits')
+ child.company = credit.company
+ child.credit_limit = credit.credit_limit
+ self.save()
+
+ if not self.payment_terms and doc.payment_terms:
+ self.payment_terms = doc.payment_terms
+
+ if not self.default_price_list and doc.default_price_list:
+ self.default_price_list = doc.default_price_list
+
def check_customer_group_change(self):
frappe.flags.customer_group_changed = False