diff --git a/accounts/doctype/sales_invoice/pos.js b/accounts/doctype/sales_invoice/pos.js index 0bae8a30d3..1a9fb12424 100644 --- a/accounts/doctype/sales_invoice/pos.js +++ b/accounts/doctype/sales_invoice/pos.js @@ -160,8 +160,10 @@ erpnext.POS = Class.extend({ parent: this.wrapper.find(".barcode-area") }); this.barcode.make_input(); - this.barcode.$input.on("change", function() { - setTimeout(me.add_item_thru_barcode(), 1000); + this.barcode.$input.on("keypress", function() { + if(me.barcode_timeout) + clearTimeout(me.barcode_timeout); + me.barcode_timeout = setTimeout(function() { me.add_item_thru_barcode(); }, 1000); }); }, make_item_list: function() { @@ -233,19 +235,23 @@ erpnext.POS = Class.extend({ me.frm.cscript.item_code(me.frm.doc, child.doctype, child.name); } }, - update_qty: function(item_code, qty) { + update_qty: function(item_code, qty, textbox_qty) { var me = this; $.each(wn.model.get_children("Sales Invoice Item", this.frm.doc.name, "entries", "Sales Invoice"), function(i, d) { if (d.item_code == item_code) { - if (qty == 1) - d.qty += 1; - else + if (textbox_qty) { + if (qty == 0 && d.item_code == item_code) + wn.model.clear_doc(d.doctype, d.name); d.qty = qty; + } + else + d.qty += 1; me.frm.cscript.qty(me.frm.doc, d.doctype, d.name); } }); + me.frm.dirty(); me.refresh(); }, refresh: function() { @@ -288,7 +294,7 @@ erpnext.POS = Class.extend({