fix(pos): customer group filter in customer selector
diff --git a/erpnext/selling/page/point_of_sale/point_of_sale.py b/erpnext/selling/page/point_of_sale/point_of_sale.py
index 993c61d..67948d7 100644
--- a/erpnext/selling/page/point_of_sale/point_of_sale.py
+++ b/erpnext/selling/page/point_of_sale/point_of_sale.py
@@ -8,7 +8,7 @@
from frappe.utils.nestedset import get_root_of
from erpnext.accounts.doctype.pos_invoice.pos_invoice import get_stock_availability
-from erpnext.accounts.doctype.pos_profile.pos_profile import get_item_groups
+from erpnext.accounts.doctype.pos_profile.pos_profile import get_child_nodes, get_item_groups
def search_by_term(search_term, warehouse, price_list):
@@ -275,3 +275,16 @@
contact_doc.set('phone_nos', [{ 'phone': value, 'is_primary_mobile_no': 1}])
frappe.db.set_value('Customer', customer, 'mobile_no', value)
contact_doc.save()
+
+@frappe.whitelist()
+def get_pos_profile_data(pos_profile):
+ pos_profile = frappe.get_doc('POS Profile', pos_profile)
+ pos_profile = pos_profile.as_dict()
+
+ _customer_groups_with_children = []
+ for row in pos_profile.customer_groups:
+ children = get_child_nodes('Customer Group', row.customer_group)
+ _customer_groups_with_children.extend(children)
+
+ pos_profile.customer_groups = _customer_groups_with_children
+ return pos_profile
\ No newline at end of file
diff --git a/erpnext/selling/page/point_of_sale/pos_controller.js b/erpnext/selling/page/point_of_sale/pos_controller.js
index ea8459f..d66c6e4 100644
--- a/erpnext/selling/page/point_of_sale/pos_controller.js
+++ b/erpnext/selling/page/point_of_sale/pos_controller.js
@@ -119,10 +119,15 @@
this.allow_negative_stock = flt(message.allow_negative_stock) || false;
});
- frappe.db.get_doc("POS Profile", this.pos_profile).then((profile) => {
- Object.assign(this.settings, profile);
- this.settings.customer_groups = profile.customer_groups.map(group => group.customer_group);
- this.make_app();
+ frappe.call({
+ method: "erpnext.selling.page.point_of_sale.point_of_sale.get_pos_profile_data",
+ args: { "pos_profile": this.pos_profile },
+ callback: (res) => {
+ const profile = res.message;
+ Object.assign(this.settings, profile);
+ this.settings.customer_groups = profile.customer_groups.map(group => group.name);
+ this.make_app();
+ }
});
}