diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.js b/erpnext/accounts/doctype/sales_invoice/sales_invoice.js index d1666380478..57e17b6da66 100644 --- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.js +++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.js @@ -23,7 +23,7 @@ erpnext.accounts.SalesInvoiceController = erpnext.selling.SellingController.exte this.frm.set_value("is_pos", 1); this.is_pos(function() { if (cint(frappe.defaults.get_user_defaults("fs_pos_view"))===1) - erpnext.pos.toggle(me.frm); + erpnext.pos.toggle(me.frm, true); }); } } @@ -75,7 +75,7 @@ erpnext.accounts.SalesInvoiceController = erpnext.selling.SellingController.exte } // Show buttons only when pos view is active - if (doc.docstatus===0 && !this.pos_active) { + if (doc.docstatus===0 && !cur_frm.page.current_view_name!=="pos") { cur_frm.cscript.sales_order_btn(); cur_frm.cscript.delivery_note_btn(); } @@ -253,7 +253,7 @@ cur_frm.cscript.mode_of_payment = function(doc) { if(r.message) { cur_frm.set_value("cash_bank_account", r.message["account"]); } - + } }); } diff --git a/erpnext/public/js/pos/pos.js b/erpnext/public/js/pos/pos.js index 46585f97376..164e88359dd 100644 --- a/erpnext/public/js/pos/pos.js +++ b/erpnext/public/js/pos/pos.js @@ -331,7 +331,7 @@ erpnext.pos.PointOfSale = Class.extend({ }, set_primary_action: function() { var me = this; - if (!this.frm.pos_active) return; + if (this.frm.page.current_view_name==="main") return; if (this.frm.doctype == "Sales Invoice" && this.frm.doc.docstatus===0) { if (!this.frm.doc.is_pos) { @@ -342,7 +342,6 @@ erpnext.pos.PointOfSale = Class.extend({ }); } else if (this.frm.doc.docstatus===1) { this.frm.page.set_primary_action(__("New"), function() { - me.frm.pos_active = false; erpnext.open_as_pos = true; new_doc(me.frm.doctype); }); @@ -464,7 +463,6 @@ erpnext.pos.PointOfSale = Class.extend({ var me = this; dialog.set_primary_action(__("Pay"), function() { var values = dialog.get_values(); - console.log(values); var is_cash = values.mode_of_payment === __("Cash"); if (!is_cash) { values.write_off_amount = values.change = 0.0; @@ -498,8 +496,8 @@ erpnext.pos.make_pos_btn = function(frm) { erpnext.pos.toggle(frm) }); } - if(erpnext.open_as_pos && !frm.pos_active) { - erpnext.pos.toggle(frm); + if(erpnext.open_as_pos && frm.page.current_view_name !== "pos") { + erpnext.pos.toggle(frm, true); } } @@ -508,12 +506,22 @@ erpnext.pos.toggle = function(frm, show) { var price_list = frappe.meta.has_field(cur_frm.doc.doctype, "selling_price_list") ? frm.doc.selling_price_list : frm.doc.buying_price_list; - if((show===true && frm.pos_active) || (show===false && !frm.pos_active)) { - return; + if(show!==undefined) { + if((show===true && frm.page.current_view_name === "pos") + || (show===false && frm.page.current_view_name === "main")) { + return; + } } - if(show && !price_list) { - frappe.throw(__("Please select Price List")); + if(frm.page.current_view_name!=="pos") { + // before switching, ask for pos name + if(!price_list) { + frappe.throw(__("Please select Price List")); + } + + if(!frm.doc.company) { + frappe.throw(__("Please select Company")); + } } // make pos @@ -523,14 +531,13 @@ erpnext.pos.toggle = function(frm, show) { } // toggle view - frm.page.set_view(frm.pos_active ? "main" : "pos"); - frm.pos_active = !frm.pos_active; + frm.page.set_view(frm.page.current_view_name==="pos" ? "main" : "pos"); frm.toolbar.current_status = null; frm.refresh(); // refresh - if(frm.pos_active) { + if(frm.page.current_view_name==="pos") { frm.pos.refresh(); } } diff --git a/erpnext/public/js/pos/pos_bill_item.html b/erpnext/public/js/pos/pos_bill_item.html index ffbebe469c0..c93c76caa6b 100644 --- a/erpnext/public/js/pos/pos_bill_item.html +++ b/erpnext/public/js/pos/pos_bill_item.html @@ -9,8 +9,8 @@ {% if(actual_qty != null) { %}
- {%= actual_qty %} - ({%= projected_qty %}) + {%= actual_qty || 0 %} + ({%= projected_qty || 0 %})
{% } %}