[pos] moved pos realted code from sales_invoice.js to transaction.js
diff --git a/accounts/doctype/sales_invoice/pos.js b/accounts/doctype/sales_invoice/pos.js
index 8837aed..67c4b93 100644
--- a/accounts/doctype/sales_invoice/pos.js
+++ b/accounts/doctype/sales_invoice/pos.js
@@ -96,6 +96,7 @@
},
make_customer: function() {
var me = this;
+ console.log(this.frm);
this.customer = wn.ui.form.make_control({
df: {
"fieldtype": "Link",
@@ -109,7 +110,7 @@
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 @@
// 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 @@
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 @@
// 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('<tr id="%(item_code)s" data-selected="false">\
<td>%(item_code)s%(item_name)s</td>\
<td><input type="text" value="%(qty)s" \
@@ -285,7 +286,7 @@
// taxes
var taxes = wn.model.get_children("Sales Taxes and Charges", this.frm.doc.name, "other_charges",
- "Sales Invoice");
+ this.frm.doctype);
$(".tax-table")
.toggle((taxes && taxes.length) ? true : false)
.find("tbody").empty();
@@ -378,8 +379,8 @@
}
}
- var child = wn.model.get_children("Sales Invoice Item", this.frm.doc.name, "entries",
- "Sales Invoice");
+ var child = wn.model.get_children(this.frm.doctype + " Item", this.frm.doc.name, "entries",
+ this.frm.doctype);
$.each(child, function(i, d) {
for (var i in selected_items) {
if (d.item_code == selected_items[i]) {
diff --git a/accounts/doctype/sales_invoice/sales_invoice.js b/accounts/doctype/sales_invoice/sales_invoice.js
index 73958fb..e49d97c 100644
--- a/accounts/doctype/sales_invoice/sales_invoice.js
+++ b/accounts/doctype/sales_invoice/sales_invoice.js
@@ -78,7 +78,7 @@
cur_frm.add_custom_button('Make Payment Entry', cur_frm.cscript.make_bank_voucher);
}
- if (doc.docstatus===0) {
+ if (doc.docstatus===0 && !this.pos_active) {
cur_frm.cscript.sales_order_btn();
cur_frm.cscript.delivery_note_btn();
}
diff --git a/public/js/transaction.js b/public/js/transaction.js
index f7caded..58dbc2d 100644
--- a/public/js/transaction.js
+++ b/public/js/transaction.js
@@ -78,11 +78,6 @@
} else {
var btn_label = wn._(this.frm.doctype) + wn._(" View"),
icon = "icon-file-text";
-
-
- if (this.frm.doc.docstatus===0) {
- this.frm.clear_custom_buttons();
- }
}
var me = this;