[hotfix] fixed Permissions Error while fetching allow_stale field value from Accounts Settings (#11182)

* [hotfix] fixed Permissions Error while fetching allow_stale field value from Accounts Settings

* [minor] renamed the allow_stale_rate method to stale_rate_allowed
This commit is contained in:
Makarand Bauskar 2017-10-25 12:17:40 +05:30 committed by Nabin Hait
parent 464289b726
commit e6712c129c
4 changed files with 9 additions and 15 deletions

View File

@ -405,11 +405,7 @@ frappe.ui.form.on('Payment Entry', {
}
// Make read only if Accounts Settings doesn't allow stale rates
frappe.model.get_value("Accounts Settings", null, "allow_stale",
function(d){
frm.set_df_property("source_exchange_rate", "read_only", cint(d.allow_stale) ? 0 : 1);
}
);
frm.set_df_property("source_exchange_rate", "read_only", erpnext.stale_rate_allowed());
},
target_exchange_rate: function(frm) {
@ -430,11 +426,7 @@ frappe.ui.form.on('Payment Entry', {
frm.set_paid_amount_based_on_received_amount = false;
// Make read only if Accounts Settings doesn't allow stale rates
frappe.model.get_value("Accounts Settings", null, "allow_stale",
function(d){
frm.set_df_property("target_exchange_rate", "read_only", cint(d.allow_stale) ? 0 : 1);
}
);
frm.set_df_property("target_exchange_rate", "read_only", erpnext.stale_rate_allowed());
},
paid_amount: function(frm) {

View File

@ -542,11 +542,7 @@ erpnext.TransactionController = erpnext.taxes_and_totals.extend({
}
// Make read only if Accounts Settings doesn't allow stale rates
frappe.model.get_value("Accounts Settings", null, "allow_stale",
function(d){
me.set_df_property("conversion_rate", "read_only", cint(d.allow_stale) ? 0 : 1);
}
);
this.frm.set_df_property("conversion_rate", "read_only", erpnext.stale_rate_allowed());
},
set_actual_charges_based_on_currency: function() {

View File

@ -37,6 +37,10 @@ $.extend(erpnext, {
}
},
stale_rate_allowed: () => {
return cint(frappe.boot.sysdefaults.allow_stale) || 1;
},
setup_serial_no: function() {
var grid_row = cur_frm.open_grid_row();
if(!grid_row || !grid_row.grid_form.fields_dict.serial_no ||

View File

@ -19,6 +19,8 @@ def boot_session(bootinfo):
'territory')
bootinfo.sysdefaults.customer_group = frappe.db.get_single_value('Selling Settings',
'customer_group')
bootinfo.sysdefaults.allow_stale = frappe.db.get_single_value('Accounts Settings',
'allow_stale') or 1
bootinfo.notification_settings = frappe.get_doc("Notification Control",
"Notification Control")