From cf3011839f6ab28f9f1d75759bdd3c9fa30b8914 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Tue, 1 Oct 2013 18:14:16 +0530 Subject: [PATCH] [fix] [minor] bind onclick function based on docstatus in pos --- accounts/doctype/sales_invoice/pos.js | 12 ++++++------ accounts/doctype/sales_invoice/sales_invoice.js | 8 ++++---- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/accounts/doctype/sales_invoice/pos.js b/accounts/doctype/sales_invoice/pos.js index 0dba40fabc..c68b9915c8 100644 --- a/accounts/doctype/sales_invoice/pos.js +++ b/accounts/doctype/sales_invoice/pos.js @@ -213,8 +213,8 @@ erpnext.POS = Class.extend({ }); // if form is local then allow this function - if (me.frm.doc.docstatus===0) { - $(me.wrapper).find("div.pos-item").on("click", function() { + $(me.wrapper).find("div.pos-item").on("click", function() { + if(me.frm.doc.docstatus==0) { if(!me.frm.doc[me.party.toLowerCase()] && ((me.frm.doctype == "Quotation" && me.frm.doc.quotation_to == "Customer") || me.frm.doctype != "Quotation")) { @@ -223,8 +223,8 @@ erpnext.POS = Class.extend({ } else me.add_to_cart($(this).attr("data-item_code")); - }); - } + } + }); } }); }, @@ -371,7 +371,7 @@ erpnext.POS = Class.extend({ }); me.refresh_delete_btn(); - this.frm.pos.barcode.$input.focus(); + this.barcode.$input.focus(); } // if form is submitted & cancelled then disable all input box & buttons @@ -476,7 +476,7 @@ erpnext.POS = Class.extend({ "total_amount": $(".grand-total").text() }); dialog.show(); - me.frm.pos.barcode.$input.focus(); + me.barcode.$input.focus(); dialog.get_input("total_amount").prop("disabled", true); diff --git a/accounts/doctype/sales_invoice/sales_invoice.js b/accounts/doctype/sales_invoice/sales_invoice.js index 4f8dda8fbe..5220c0fa20 100644 --- a/accounts/doctype/sales_invoice/sales_invoice.js +++ b/accounts/doctype/sales_invoice/sales_invoice.js @@ -29,11 +29,10 @@ erpnext.accounts.SalesInvoiceController = erpnext.selling.SellingController.exte // toggle to pos view if is_pos is 1 in user_defaults if ((cint(wn.defaults.get_user_defaults("is_pos"))===1 || cur_frm.doc.is_pos) && cint(wn.defaults.get_user_defaults("fs_pos_view"))===1) { - if(this.frm.doc.__islocal) { + if(this.frm.doc.__islocal && !this.frm.doc.amended_from) { this.frm.set_value("is_pos", 1); - this.is_pos(); + this.is_pos(function() {cur_frm.cscript.toggle_pos(true);}); } - cur_frm.cscript.toggle_pos(true); } // if document is POS then change default print format to "POS Invoice" @@ -128,7 +127,7 @@ erpnext.accounts.SalesInvoiceController = erpnext.selling.SellingController.exte this.get_terms(); }, - is_pos: function() { + is_pos: function(callback_fn) { cur_frm.cscript.hide_fields(this.frm.doc); if(cint(this.frm.doc.is_pos)) { if(!this.frm.doc.company) { @@ -142,6 +141,7 @@ erpnext.accounts.SalesInvoiceController = erpnext.selling.SellingController.exte callback: function(r) { if(!r.exc) { me.frm.script_manager.trigger("update_stock"); + if(callback_fn) callback_fn() } } });