[fix] In payment entry, run some events serially to avoid async issue

This commit is contained in:
Nabin Hait 2017-11-22 15:13:16 +05:30
parent 75443a94ee
commit 96abfd2ab9

View File

@ -253,20 +253,24 @@ frappe.ui.form.on('Payment Entry', {
}, },
callback: function(r, rt) { callback: function(r, rt) {
if(r.message) { if(r.message) {
if(frm.doc.payment_type == "Receive") { frappe.run_serially([
frm.set_value("paid_from", r.message.party_account); () => {
frm.set_value("paid_from_account_currency", r.message.party_account_currency); if(frm.doc.payment_type == "Receive") {
frm.set_value("paid_from_account_balance", r.message.account_balance); frm.set_value("paid_from", r.message.party_account);
} else if (frm.doc.payment_type == "Pay"){ frm.set_value("paid_from_account_currency", r.message.party_account_currency);
frm.set_value("paid_to", r.message.party_account); frm.set_value("paid_from_account_balance", r.message.account_balance);
frm.set_value("paid_to_account_currency", r.message.party_account_currency); } else if (frm.doc.payment_type == "Pay"){
frm.set_value("paid_to_account_balance", r.message.account_balance); frm.set_value("paid_to", r.message.party_account);
} frm.set_value("paid_to_account_currency", r.message.party_account_currency);
frm.set_value("party_balance", r.message.party_balance); frm.set_value("paid_to_account_balance", r.message.account_balance);
frm.events.get_outstanding_documents(frm); }
frm.events.hide_unhide_fields(frm); },
frm.events.set_dynamic_labels(frm); () => frm.set_value("party_balance", r.message.party_balance),
frm.set_party_account_based_on_party = false; () => frm.events.get_outstanding_documents(frm),
() => frm.events.hide_unhide_fields(frm),
() => frm.events.set_dynamic_labels(frm),
() => { frm.set_party_account_based_on_party = false; }
]);
} }
} }
}); });