[pos] [minor] fix for cur_frm

This commit is contained in:
Akhilesh Darjee
2013-09-27 12:32:26 +05:30
parent 10dce341c8
commit 2428e8d1b7
2 changed files with 23 additions and 23 deletions

View File

@@ -213,10 +213,10 @@ erpnext.POS = Class.extend({
}); });
// if form is local then allow this function // if form is local then allow this function
if (cur_frm.doc.docstatus===0) { if (me.frm.doc.docstatus===0) {
$("div.pos-item").on("click", function() { $("div.pos-item").on("click", function() {
if(!cur_frm.doc[me.party.toLowerCase()] && ((me.frm.doctype == "Quotation" && if(!me.frm.doc[me.party.toLowerCase()] && ((me.frm.doctype == "Quotation" &&
cur_frm.doc.quotation_to == "Customer") me.frm.doc.quotation_to == "Customer")
|| me.frm.doctype != "Quotation")) { || me.frm.doctype != "Quotation")) {
msgprint("Please select " + me.party + " first."); msgprint("Please select " + me.party + " first.");
return; return;
@@ -304,8 +304,8 @@ erpnext.POS = Class.extend({
item_code: d.item_code, item_code: d.item_code,
item_name: d.item_name===d.item_code ? "" : ("<br>" + d.item_name), item_name: d.item_name===d.item_code ? "" : ("<br>" + d.item_name),
qty: d.qty, qty: d.qty,
rate: format_currency(rate, cur_frm.doc.currency), rate: format_currency(rate, me.frm.doc.currency),
amount: format_currency(item_amount, cur_frm.doc.currency) amount: format_currency(item_amount, me.frm.doc.currency)
} }
)).appendTo($items); )).appendTo($items);
}); });
@@ -332,19 +332,19 @@ erpnext.POS = Class.extend({
// set totals // set totals
if (this.sales_or_purchase == "Sales") { if (this.sales_or_purchase == "Sales") {
this.wrapper.find(".net-total").text(format_currency(this.frm.doc.net_total_export, this.wrapper.find(".net-total").text(format_currency(this.frm.doc.net_total_export,
cur_frm.doc.currency)); me.frm.doc.currency));
this.wrapper.find(".grand-total").text(format_currency(this.frm.doc.grand_total_export, this.wrapper.find(".grand-total").text(format_currency(this.frm.doc.grand_total_export,
cur_frm.doc.currency)); me.frm.doc.currency));
} }
else { else {
this.wrapper.find(".net-total").text(format_currency(this.frm.doc.net_total_import, this.wrapper.find(".net-total").text(format_currency(this.frm.doc.net_total_import,
cur_frm.doc.currency)); me.frm.doc.currency));
this.wrapper.find(".grand-total").text(format_currency(this.frm.doc.grand_total_import, this.wrapper.find(".grand-total").text(format_currency(this.frm.doc.grand_total_import,
cur_frm.doc.currency)); me.frm.doc.currency));
} }
// if form is local then only run all these functions // if form is local then only run all these functions
if (cur_frm.doc.docstatus===0) { if (this.frm.doc.docstatus===0) {
$("input.qty").on("focus", function() { $("input.qty").on("focus", function() {
$(this).select(); $(this).select();
}); });
@@ -371,11 +371,11 @@ erpnext.POS = Class.extend({
}); });
me.refresh_delete_btn(); me.refresh_delete_btn();
cur_frm.pos.barcode.$input.focus(); this.frm.pos.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
if (cur_frm.doc.docstatus>=1) { if (this.frm.doc.docstatus>=1) {
me.wrapper.find('input, button').each(function () { me.wrapper.find('input, button').each(function () {
$(this).prop('disabled', true); $(this).prop('disabled', true);
}); });
@@ -390,7 +390,7 @@ erpnext.POS = Class.extend({
// If quotation to is not Customer then remove party // If quotation to is not Customer then remove party
if (this.frm.doctype == "Quotation") { if (this.frm.doctype == "Quotation") {
this.party_field.$wrapper.remove(); this.party_field.$wrapper.remove();
if (cur_frm.doc.quotation_to == "Customer") if (this.frm.doc.quotation_to == "Customer")
this.make_party(); this.make_party();
} }
}, },
@@ -435,8 +435,8 @@ erpnext.POS = Class.extend({
} }
} }
}); });
cur_frm.fields_dict[this.frm.cscript.fname].grid.refresh(); this.frm.fields_dict[this.frm.cscript.fname].grid.refresh();
cur_frm.script_manager.trigger("calculate_taxes_and_totals"); this.frm.script_manager.trigger("calculate_taxes_and_totals");
me.frm.dirty(); me.frm.dirty();
me.refresh(); me.refresh();
}, },
@@ -470,15 +470,15 @@ erpnext.POS = Class.extend({
"total_amount": $(".grand-total").text() "total_amount": $(".grand-total").text()
}); });
dialog.show(); dialog.show();
cur_frm.pos.barcode.$input.focus(); me.frm.pos.barcode.$input.focus();
dialog.get_input("total_amount").prop("disabled", true); dialog.get_input("total_amount").prop("disabled", true);
dialog.fields_dict.pay.input.onclick = function() { dialog.fields_dict.pay.input.onclick = function() {
cur_frm.set_value("mode_of_payment", dialog.get_values().mode_of_payment); me.frm.set_value("mode_of_payment", dialog.get_values().mode_of_payment);
cur_frm.set_value("paid_amount", dialog.get_values().total_amount); me.frm.set_value("paid_amount", dialog.get_values().total_amount);
cur_frm.cscript.mode_of_payment(cur_frm.doc); me.frm.cscript.mode_of_payment(me.frm.doc);
cur_frm.save(); me.frm.save();
dialog.hide(); dialog.hide();
me.refresh(); me.refresh();
}; };

View File

@@ -83,12 +83,12 @@ erpnext.selling.QuotationController = erpnext.selling.SellingController.extend({
}, },
validate_company_and_party: function(party_field) { validate_company_and_party: function(party_field) {
if(this.frm.doc.quotation_to == "Lead") { if(!this.frm.doc.quotation_to) {
return true;
} else if(!this.frm.doc.quotation_to) {
msgprint(wn._("Please select a value for" + " " + wn.meta.get_label(this.frm.doc.doctype, msgprint(wn._("Please select a value for" + " " + wn.meta.get_label(this.frm.doc.doctype,
"quotation_to", this.frm.doc.name))); "quotation_to", this.frm.doc.name)));
return false; return false;
} else if (this.frm.doc.quotation_to == "Lead") {
return true;
} else { } else {
return this._super(party_field); return this._super(party_field);
} }