fix: broken UI on currency exchange

(cherry picked from commit e91b65e7bd)
This commit is contained in:
ruthra kumar
2024-11-15 11:05:01 +05:30
committed by Mergify
parent 50d15249fc
commit f4603910e4

View File

@@ -1,30 +1,32 @@
// Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors // Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
// License: GNU General Public License v3. See license.txt // License: GNU General Public License v3. See license.txt
extend_cscript(cur_frm.cscript, { frappe.ui.form.on("Currency Exchange", {
onload: function () { onload: function (frm) {
if (cur_frm.doc.__islocal) { if (frm.doc.__islocal) {
cur_frm.set_value("to_currency", frappe.defaults.get_global_default("currency")); frm.set_value("to_currency", frappe.defaults.get_global_default("currency"));
} }
}, },
refresh: function () { refresh: function (frm) {
cur_frm.cscript.set_exchange_rate_label(); // Don't trigger on Quick Entry form
if (typeof frm.is_dialog === "undefined") {
frm.trigger("set_exchange_rate_label");
}
}, },
from_currency: function () { from_currency: function (frm) {
cur_frm.cscript.set_exchange_rate_label(); frm.trigger("set_exchange_rate_label");
}, },
to_currency: function () { to_currency: function (frm) {
cur_frm.cscript.set_exchange_rate_label(); frm.trigger("set_exchange_rate_label");
}, },
set_exchange_rate_label: function (frm) {
set_exchange_rate_label: function () { if (frm.doc.from_currency && frm.doc.to_currency) {
if (cur_frm.doc.from_currency && cur_frm.doc.to_currency) { var default_label = __(frappe.meta.docfield_map[frm.doctype]["exchange_rate"].label);
var default_label = __(frappe.meta.docfield_map[cur_frm.doctype]["exchange_rate"].label); frm.fields_dict.exchange_rate.set_label(
cur_frm.fields_dict.exchange_rate.set_label( default_label + repl(" (1 %(from_currency)s = [?] %(to_currency)s)", frm.doc)
default_label + repl(" (1 %(from_currency)s = [?] %(to_currency)s)", cur_frm.doc)
); );
} }
}, },