From a550e7443fa9c1a6ff6f0224db0764dcf7271179 Mon Sep 17 00:00:00 2001 From: Akhilesh Darjee Date: Tue, 17 Sep 2013 18:52:00 +0530 Subject: [PATCH] [pos] moved pos realted code from sales_invoice.js to transaction.js --- accounts/doctype/sales_invoice/pos.js | 23 ++++++++++--------- .../doctype/sales_invoice/sales_invoice.js | 2 +- public/js/transaction.js | 5 ---- 3 files changed, 13 insertions(+), 17 deletions(-) diff --git a/accounts/doctype/sales_invoice/pos.js b/accounts/doctype/sales_invoice/pos.js index 8837aed14b..67c4b93186 100644 --- a/accounts/doctype/sales_invoice/pos.js +++ b/accounts/doctype/sales_invoice/pos.js @@ -96,6 +96,7 @@ erpnext.POS = Class.extend({ }, make_customer: function() { var me = this; + console.log(this.frm); this.customer = wn.ui.form.make_control({ df: { "fieldtype": "Link", @@ -109,7 +110,7 @@ erpnext.POS = Class.extend({ this.customer.make_input(); this.customer.$input.on("change", function() { if(!me.customer.autocomplete_open) - wn.model.set_value("Sales Invoice", me.frm.docname, "customer", this.value); + wn.model.set_value(this.frm.doctype, me.frm.docname, "customer", this.value); }); }, make_item_group: function() { @@ -221,8 +222,8 @@ erpnext.POS = Class.extend({ // check whether the item is already added if (no_of_items != 0) { - $.each(wn.model.get_children("Sales Invoice Item", this.frm.doc.name, "entries", - "Sales Invoice"), function(i, d) { + $.each(wn.model.get_children(this.frm.doctype + " Item", this.frm.doc.name, "entries", + this.frm.doctype), function(i, d) { if (d.item_code == item_code) caught = true; }); @@ -233,15 +234,15 @@ erpnext.POS = Class.extend({ me.update_qty(item_code, 1); } else { - var child = wn.model.add_child(me.frm.doc, "Sales Invoice Item", "entries"); + var child = wn.model.add_child(me.frm.doc, this.frm.doctype + " Item", "entries"); child.item_code = item_code; me.frm.cscript.item_code(me.frm.doc, child.doctype, child.name); } }, 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) { + $.each(wn.model.get_children(this.frm.doctype + " Item", this.frm.doc.name, "entries", + this.frm.doctype), function(i, d) { if (d.item_code == item_code) { if (textbox_qty) { if (qty == 0 && d.item_code == item_code) @@ -265,8 +266,8 @@ erpnext.POS = Class.extend({ // add items var $items = me.wrapper.find("#cart tbody").empty(); - $.each(wn.model.get_children("Sales Invoice Item", this.frm.doc.name, "entries", - "Sales Invoice"), function(i, d) { + $.each(wn.model.get_children(this.frm.doctype + " Item", this.frm.doc.name, "entries", + this.frm.doctype), function(i, d) { $(repl('\ %(item_code)s%(item_name)s\