Load default pos profile if not found
diff --git a/erpnext/accounts/doctype/pos_profile/pos_profile.py b/erpnext/accounts/doctype/pos_profile/pos_profile.py
index 3e37285..6b7d99f 100644
--- a/erpnext/accounts/doctype/pos_profile/pos_profile.py
+++ b/erpnext/accounts/doctype/pos_profile/pos_profile.py
@@ -132,6 +132,7 @@
return out
@frappe.whitelist()
-def get_pos_profile(pos_profile_name):
+def get_pos_profile(pos_profile_name=None):
+ if not pos_profile_name: return
name = frappe.db.get_value('POS Profile', { 'pos_profile_name': pos_profile_name })
return frappe.get_doc('POS Profile', name)
diff --git a/erpnext/selling/page/point_of_sale/point_of_sale.js b/erpnext/selling/page/point_of_sale/point_of_sale.js
index ee6a633..c9893f1 100644
--- a/erpnext/selling/page/point_of_sale/point_of_sale.js
+++ b/erpnext/selling/page/point_of_sale/point_of_sale.js
@@ -284,17 +284,22 @@
setup_pos_profile() {
return new Promise((resolve) => {
+
+ const load_default = () => {
+ this.pos_profile = {
+ company: this.company,
+ currency: frappe.defaults.get_default('currency'),
+ selling_price_list: frappe.defaults.get_default('selling_price_list')
+ };
+ resolve();
+ }
+
const on_submit = ({ pos_profile }) => {
this.get_pos_profile_doc(pos_profile)
.then(doc => {
this.pos_profile = doc;
-
if (!this.pos_profile) {
- this.pos_profile = {
- company: this.company,
- currency: frappe.defaults.get_default('currency'),
- selling_price_list: frappe.defaults.get_default('selling_price_list')
- };
+ load_default();
}
resolve();
});
@@ -304,9 +309,11 @@
method: 'erpnext.accounts.doctype.pos_profile.pos_profile.get_pos_profiles_for_user'
}).then((r) => {
if (r && r.message) {
- const pos_profiles = r.message;
+ const pos_profiles = r.message.filter(a => a);
- if(pos_profiles.length === 1) {
+ if (pos_profiles.length === 0) {
+ load_default();
+ } else if(pos_profiles.length === 1) {
// load profile directly
on_submit({pos_profile: pos_profiles[0]});
} else {