fix: Use extend_cscript function to properly extend class methods to cscript

This commit is contained in:
Suraj Shetty
2021-05-21 17:03:09 +05:30
parent 94a52c0e17
commit 81d49e9c71
23 changed files with 42 additions and 35 deletions

View File

@@ -1,30 +1,30 @@
// Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
// License: GNU General Public License v3. See license.txt
$.extend(cur_frm.cscript, {
extend_cscript(cur_frm.cscript, {
onload: function() {
if(cur_frm.doc.__islocal) {
cur_frm.set_value("to_currency", frappe.defaults.get_global_default("currency"));
}
},
refresh: function() {
cur_frm.cscript.set_exchange_rate_label();
},
from_currency: function() {
cur_frm.cscript.set_exchange_rate_label();
},
to_currency: function() {
cur_frm.cscript.set_exchange_rate_label();
},
set_exchange_rate_label: function() {
if(cur_frm.doc.from_currency && cur_frm.doc.to_currency) {
var default_label = __(frappe.meta.docfield_map[cur_frm.doctype]["exchange_rate"].label);
cur_frm.fields_dict.exchange_rate.set_label(default_label +
cur_frm.fields_dict.exchange_rate.set_label(default_label +
repl(" (1 %(from_currency)s = [?] %(to_currency)s)", cur_frm.doc));
}
}
});
});