Fixed can freeze account check for account doc in client side
This commit is contained in:
parent
33003c6168
commit
04f8990c11
@ -19,13 +19,7 @@ cur_frm.cscript.refresh = function(doc, cdt, cdn) {
|
|||||||
cur_frm.toggle_enable(['account_name', 'group_or_ledger', 'company'], false);
|
cur_frm.toggle_enable(['account_name', 'group_or_ledger', 'company'], false);
|
||||||
|
|
||||||
if(doc.group_or_ledger=='Ledger') {
|
if(doc.group_or_ledger=='Ledger') {
|
||||||
frappe.model.with_doc("Accounts Settings", "Accounts Settings", function (name) {
|
cur_frm.toggle_display('freeze_account', doc.can_freeze_account);
|
||||||
var accounts_settings = frappe.get_doc("Accounts Settings", name);
|
|
||||||
var display = accounts_settings["frozen_accounts_modifier"]
|
|
||||||
&& in_list(user_roles, accounts_settings["frozen_accounts_modifier"]);
|
|
||||||
|
|
||||||
cur_frm.toggle_display('freeze_account', display);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// read-only for root accounts
|
// read-only for root accounts
|
||||||
|
@ -10,6 +10,19 @@ from frappe.model.document import Document
|
|||||||
class Account(Document):
|
class Account(Document):
|
||||||
nsm_parent_field = 'parent_account'
|
nsm_parent_field = 'parent_account'
|
||||||
|
|
||||||
|
def onload(self):
|
||||||
|
frozen_accounts_modifier = frappe.db.get_value("Accounts Settings", "Accounts Settings", "frozen_accounts_modifier")
|
||||||
|
print frozen_accounts_modifier
|
||||||
|
if frozen_accounts_modifier in frappe.user.get_roles():
|
||||||
|
self.can_freeze_account = True
|
||||||
|
|
||||||
|
def as_dict(self, no_nulls=False):
|
||||||
|
doc = super(Account, self).as_dict(no_nulls)
|
||||||
|
if self.get("can_freeze_account"):
|
||||||
|
doc["can_freeze_account"] = self.can_freeze_account
|
||||||
|
|
||||||
|
return doc
|
||||||
|
|
||||||
def autoname(self):
|
def autoname(self):
|
||||||
self.name = self.account_name.strip() + ' - ' + \
|
self.name = self.account_name.strip() + ' - ' + \
|
||||||
frappe.db.get_value("Company", self.company, "abbr")
|
frappe.db.get_value("Company", self.company, "abbr")
|
||||||
@ -63,8 +76,7 @@ class Account(Document):
|
|||||||
def validate_frozen_accounts_modifier(self):
|
def validate_frozen_accounts_modifier(self):
|
||||||
old_value = frappe.db.get_value("Account", self.name, "freeze_account")
|
old_value = frappe.db.get_value("Account", self.name, "freeze_account")
|
||||||
if old_value and old_value != self.freeze_account:
|
if old_value and old_value != self.freeze_account:
|
||||||
frozen_accounts_modifier = frappe.db.get_value( 'Accounts Settings', None,
|
frozen_accounts_modifier = frappe.db.get_value('Accounts Settings', None, 'frozen_accounts_modifier')
|
||||||
'frozen_accounts_modifier')
|
|
||||||
if not frozen_accounts_modifier or \
|
if not frozen_accounts_modifier or \
|
||||||
frozen_accounts_modifier not in frappe.user.get_roles():
|
frozen_accounts_modifier not in frappe.user.get_roles():
|
||||||
throw(_("You are not authorized to set Frozen value"))
|
throw(_("You are not authorized to set Frozen value"))
|
||||||
|
Loading…
Reference in New Issue
Block a user