[fix] [minor] bind onclick function based on docstatus in pos

This commit is contained in:
Nabin Hait
2013-10-01 18:14:16 +05:30
parent 49e71400ac
commit cf3011839f
2 changed files with 10 additions and 10 deletions

View File

@@ -213,8 +213,8 @@ erpnext.POS = Class.extend({
}); });
// if form is local then allow this function // 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" && if(!me.frm.doc[me.party.toLowerCase()] && ((me.frm.doctype == "Quotation" &&
me.frm.doc.quotation_to == "Customer") me.frm.doc.quotation_to == "Customer")
|| me.frm.doctype != "Quotation")) { || me.frm.doctype != "Quotation")) {
@@ -223,8 +223,8 @@ erpnext.POS = Class.extend({
} }
else else
me.add_to_cart($(this).attr("data-item_code")); me.add_to_cart($(this).attr("data-item_code"));
}); }
} });
} }
}); });
}, },
@@ -371,7 +371,7 @@ erpnext.POS = Class.extend({
}); });
me.refresh_delete_btn(); 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 // if form is submitted & cancelled then disable all input box & buttons
@@ -476,7 +476,7 @@ erpnext.POS = Class.extend({
"total_amount": $(".grand-total").text() "total_amount": $(".grand-total").text()
}); });
dialog.show(); dialog.show();
me.frm.pos.barcode.$input.focus(); me.barcode.$input.focus();
dialog.get_input("total_amount").prop("disabled", true); dialog.get_input("total_amount").prop("disabled", true);

View File

@@ -29,11 +29,10 @@ erpnext.accounts.SalesInvoiceController = erpnext.selling.SellingController.exte
// toggle to pos view if is_pos is 1 in user_defaults // 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) && 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) { 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.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" // 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(); this.get_terms();
}, },
is_pos: function() { is_pos: function(callback_fn) {
cur_frm.cscript.hide_fields(this.frm.doc); cur_frm.cscript.hide_fields(this.frm.doc);
if(cint(this.frm.doc.is_pos)) { if(cint(this.frm.doc.is_pos)) {
if(!this.frm.doc.company) { if(!this.frm.doc.company) {
@@ -142,6 +141,7 @@ erpnext.accounts.SalesInvoiceController = erpnext.selling.SellingController.exte
callback: function(r) { callback: function(r) {
if(!r.exc) { if(!r.exc) {
me.frm.script_manager.trigger("update_stock"); me.frm.script_manager.trigger("update_stock");
if(callback_fn) callback_fn()
} }
} }
}); });