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 4c0f42d22e..308b8edd3b 100644 --- a/erpnext/selling/page/point_of_sale/point_of_sale.js +++ b/erpnext/selling/page/point_of_sale/point_of_sale.js @@ -54,8 +54,16 @@ erpnext.pos.PointOfSale = class PointOfSale { this.prepare_menu(); this.set_online_status(); }, - () => this.setup_company(), () => this.make_new_invoice(), + () => { + if(!this.frm.doc.company) { + this.setup_company() + .then((company) => { + this.frm.doc.company = company; + this.get_pos_profile(); + }); + } + }, () => { frappe.dom.unfreeze(); }, @@ -63,6 +71,22 @@ erpnext.pos.PointOfSale = class PointOfSale { ]); } + get_pos_profile() { + return frappe.xcall("erpnext.stock.get_item_details.get_pos_profile", + {'company': this.frm.doc.company}) + .then((r) => { + if(r) { + this.frm.doc.pos_profile = r.name; + this.set_pos_profile_data() + .then(() => { + this.on_change_pos_profile(); + }); + } else { + this.raise_exception_for_pos_profile(); + } + }); + } + set_online_status() { this.connection_status = false; this.page.set_indicator(__("Offline"), "grey"); @@ -77,6 +101,11 @@ erpnext.pos.PointOfSale = class PointOfSale { }); } + raise_exception_for_pos_profile() { + setTimeout(() => frappe.set_route('List', 'POS Profile'), 2000); + frappe.throw(__("POS Profile is required to use Point-of-Sale")); + } + prepare_dom() { this.wrapper.append(`