Merge pull request #1342 from akhileshdarjee/hotfix
Item List refresh when price list changed in POS
This commit is contained in:
commit
af21479665
@ -109,6 +109,7 @@ erpnext.POS = Class.extend({
|
|||||||
this.party = party;
|
this.party = party;
|
||||||
this.price_list = (party == "Customer" ?
|
this.price_list = (party == "Customer" ?
|
||||||
this.frm.doc.selling_price_list : this.frm.doc.buying_price_list);
|
this.frm.doc.selling_price_list : this.frm.doc.buying_price_list);
|
||||||
|
this.price_list_field = (party == "Customer" ? "selling_price_list" : "buying_price_list");
|
||||||
this.sales_or_purchase = (party == "Customer" ? "Sales" : "Purchase");
|
this.sales_or_purchase = (party == "Customer" ? "Sales" : "Purchase");
|
||||||
this.net_total = "net_total_" + export_or_import;
|
this.net_total = "net_total_" + export_or_import;
|
||||||
this.grand_total = "grand_total_" + export_or_import;
|
this.grand_total = "grand_total_" + export_or_import;
|
||||||
@ -269,22 +270,17 @@ erpnext.POS = Class.extend({
|
|||||||
this.frm.cscript.fname, this.frm.doctype), function(i, d) {
|
this.frm.cscript.fname, this.frm.doctype), function(i, d) {
|
||||||
if (d.item_code == item_code) {
|
if (d.item_code == item_code) {
|
||||||
caught = true;
|
caught = true;
|
||||||
if (serial_no) {
|
if (serial_no)
|
||||||
d.serial_no += '\n' + serial_no;
|
wn.model.set_value(d.doctype, d.name, "serial_no", d.serial_no + '\n' + serial_no);
|
||||||
me.frm.script_manager.trigger("serial_no", d.doctype, d.name);
|
else
|
||||||
}
|
wn.model.set_value(d.doctype, d.name, "qty", d.qty + 1);
|
||||||
else {
|
|
||||||
d.qty += 1;
|
|
||||||
me.frm.script_manager.trigger("qty", d.doctype, d.name);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// if item not found then add new item
|
// if item not found then add new item
|
||||||
if (!caught) {
|
if (!caught)
|
||||||
this.add_new_item_to_grid(item_code, serial_no);
|
this.add_new_item_to_grid(item_code, serial_no);
|
||||||
}
|
|
||||||
|
|
||||||
this.refresh();
|
this.refresh();
|
||||||
this.refresh_search_box();
|
this.refresh_search_box();
|
||||||
@ -319,15 +315,16 @@ erpnext.POS = Class.extend({
|
|||||||
wn.model.clear_doc(d.doctype, d.name);
|
wn.model.clear_doc(d.doctype, d.name);
|
||||||
me.refresh_grid();
|
me.refresh_grid();
|
||||||
} else {
|
} else {
|
||||||
d.qty = qty;
|
wn.model.set_value(d.doctype, d.name, "qty", qty);
|
||||||
me.frm.script_manager.trigger("qty", d.doctype, d.name);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
me.refresh();
|
this.refresh();
|
||||||
},
|
},
|
||||||
refresh: function() {
|
refresh: function() {
|
||||||
var me = this;
|
var me = this;
|
||||||
|
|
||||||
|
this.refresh_item_list();
|
||||||
this.party_field.set_input(this.frm.doc[this.party.toLowerCase()]);
|
this.party_field.set_input(this.frm.doc[this.party.toLowerCase()]);
|
||||||
this.barcode.set_input("");
|
this.barcode.set_input("");
|
||||||
|
|
||||||
@ -350,6 +347,14 @@ erpnext.POS = Class.extend({
|
|||||||
this.make_party();
|
this.make_party();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
refresh_item_list: function() {
|
||||||
|
var me = this;
|
||||||
|
// refresh item list on change of price list
|
||||||
|
if (this.frm.doc[this.price_list_field] != this.price_list) {
|
||||||
|
this.price_list = this.frm.doc[this.price_list_field];
|
||||||
|
this.make_item_list();
|
||||||
|
}
|
||||||
|
},
|
||||||
show_items_in_item_cart: function() {
|
show_items_in_item_cart: function() {
|
||||||
var me = this;
|
var me = this;
|
||||||
var $items = this.wrapper.find("#cart tbody").empty();
|
var $items = this.wrapper.find("#cart tbody").empty();
|
||||||
@ -383,9 +388,8 @@ erpnext.POS = Class.extend({
|
|||||||
)).appendTo($items);
|
)).appendTo($items);
|
||||||
});
|
});
|
||||||
|
|
||||||
this.wrapper.find(".increase-qty, .decrease-qty").on("click", function() {
|
this.wrapper.find("input.qty").on("focus", function() {
|
||||||
var item_code = $(this).closest("tr").attr("id");
|
$(this).select();
|
||||||
me.selected_item_qty_operation(item_code, $(this).attr("class"));
|
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
show_taxes: function() {
|
show_taxes: function() {
|
||||||
@ -422,10 +426,16 @@ erpnext.POS = Class.extend({
|
|||||||
|
|
||||||
// append quantity to the respective item after change from input box
|
// append quantity to the respective item after change from input box
|
||||||
$(this.wrapper).find("input.qty").on("change", function() {
|
$(this.wrapper).find("input.qty").on("change", function() {
|
||||||
var item_code = $(this).closest("tr")[0].id;
|
var item_code = $(this).closest("tr").attr("id");
|
||||||
me.update_qty(item_code, $(this).val());
|
me.update_qty(item_code, $(this).val());
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// increase/decrease qty on plus/minus button
|
||||||
|
$(this.wrapper).find(".increase-qty, .decrease-qty").on("click", function() {
|
||||||
|
var tr = $(this).closest("tr");
|
||||||
|
me.increase_decrease_qty(tr, $(this).attr("class"));
|
||||||
|
});
|
||||||
|
|
||||||
// on td click toggle the highlighting of row
|
// on td click toggle the highlighting of row
|
||||||
$(this.wrapper).find("#cart tbody tr td").on("click", function() {
|
$(this.wrapper).find("#cart tbody tr td").on("click", function() {
|
||||||
var row = $(this).closest("tr");
|
var row = $(this).closest("tr");
|
||||||
@ -443,6 +453,15 @@ erpnext.POS = Class.extend({
|
|||||||
me.refresh_delete_btn();
|
me.refresh_delete_btn();
|
||||||
this.barcode.$input.focus();
|
this.barcode.$input.focus();
|
||||||
},
|
},
|
||||||
|
increase_decrease_qty: function(tr, operation) {
|
||||||
|
var item_code = tr.attr("id");
|
||||||
|
var item_qty = cint(tr.find("input.qty").val());
|
||||||
|
|
||||||
|
if (operation == "increase-qty")
|
||||||
|
this.update_qty(item_code, item_qty + 1);
|
||||||
|
else if (operation == "decrease-qty" && item_qty != 1)
|
||||||
|
this.update_qty(item_code, item_qty - 1);
|
||||||
|
},
|
||||||
disable_text_box_and_button: function() {
|
disable_text_box_and_button: function() {
|
||||||
var me = this;
|
var me = this;
|
||||||
// if form is submitted & cancelled then disable all input box & buttons
|
// if form is submitted & cancelled then disable all input box & buttons
|
||||||
@ -514,27 +533,11 @@ erpnext.POS = Class.extend({
|
|||||||
this.refresh_grid();
|
this.refresh_grid();
|
||||||
},
|
},
|
||||||
refresh_grid: function() {
|
refresh_grid: function() {
|
||||||
|
this.frm.dirty();
|
||||||
this.frm.fields_dict[this.frm.cscript.fname].grid.refresh();
|
this.frm.fields_dict[this.frm.cscript.fname].grid.refresh();
|
||||||
this.frm.script_manager.trigger("calculate_taxes_and_totals");
|
this.frm.script_manager.trigger("calculate_taxes_and_totals");
|
||||||
this.refresh();
|
this.refresh();
|
||||||
},
|
},
|
||||||
selected_item_qty_operation: function(item_code, operation) {
|
|
||||||
var me = this;
|
|
||||||
var child = wn.model.get_children(this.frm.doctype + " Item", this.frm.doc.name,
|
|
||||||
this.frm.cscript.fname, this.frm.doctype);
|
|
||||||
|
|
||||||
$.each(child, function(i, d) {
|
|
||||||
if (d.item_code == item_code) {
|
|
||||||
if (operation == "increase-qty")
|
|
||||||
d.qty += 1;
|
|
||||||
else if (operation == "decrease-qty")
|
|
||||||
d.qty != 1 ? d.qty -= 1 : d.qty = 1;
|
|
||||||
|
|
||||||
me.frm.script_manager.trigger("qty", d.doctype, d.name);
|
|
||||||
me.refresh();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
},
|
|
||||||
make_payment: function() {
|
make_payment: function() {
|
||||||
var me = this;
|
var me = this;
|
||||||
var no_of_items = $(this.wrapper).find("#cart tbody tr").length;
|
var no_of_items = $(this.wrapper).find("#cart tbody tr").length;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user