From 6c66096fa57da7bc03589191e1fd741a2ccd9c13 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Tue, 24 Sep 2013 00:10:10 +0530 Subject: [PATCH] [minor] allowed role to edit entries against frozen accounts --- accounts/doctype/account/account.txt | 4 ++-- .../accounts_settings/accounts_settings.txt | 12 ++++++++++-- accounts/doctype/gl_entry/gl_entry.py | 15 +++++++++++---- 3 files changed, 23 insertions(+), 8 deletions(-) diff --git a/accounts/doctype/account/account.txt b/accounts/doctype/account/account.txt index 7a6ebf8dac..da3b50f644 100644 --- a/accounts/doctype/account/account.txt +++ b/accounts/doctype/account/account.txt @@ -2,7 +2,7 @@ { "creation": "2013-01-30 12:49:46", "docstatus": 0, - "modified": "2013-07-05 14:23:30", + "modified": "2013-09-23 23:55:15", "modified_by": "Administrator", "owner": "Administrator" }, @@ -179,7 +179,7 @@ "reqd": 0 }, { - "description": "If the account is frozen, entries are allowed for the \"Account Manager\" only.", + "description": "If the account is frozen, entries are allowed to restricted users.", "doctype": "DocField", "fieldname": "freeze_account", "fieldtype": "Select", diff --git a/accounts/doctype/accounts_settings/accounts_settings.txt b/accounts/doctype/accounts_settings/accounts_settings.txt index b8be161427..67b3901976 100644 --- a/accounts/doctype/accounts_settings/accounts_settings.txt +++ b/accounts/doctype/accounts_settings/accounts_settings.txt @@ -2,7 +2,7 @@ { "creation": "2013-06-24 15:49:57", "docstatus": 0, - "modified": "2013-07-05 14:23:40", + "modified": "2013-09-23 23:53:25", "modified_by": "Administrator", "owner": "Administrator" }, @@ -57,7 +57,15 @@ "doctype": "DocField", "fieldname": "bde_auth_role", "fieldtype": "Link", - "label": "Allow Editing of Frozen Accounts For", + "label": "Allowed Role to Edit Entries Before Frozen Date", + "options": "Role" + }, + { + "description": "Users with this role are allowed to do / modify accounting entries against frozen accounts", + "doctype": "DocField", + "fieldname": "frozen_accounts_modifier", + "fieldtype": "Link", + "label": "Allowed Role to Edit Entries against Frozen Accounts", "options": "Role" }, { diff --git a/accounts/doctype/gl_entry/gl_entry.py b/accounts/doctype/gl_entry/gl_entry.py index 9c1cf3fa67..d56d14acfe 100644 --- a/accounts/doctype/gl_entry/gl_entry.py +++ b/accounts/doctype/gl_entry/gl_entry.py @@ -91,10 +91,17 @@ class DocType: msgprint(_("Account") + ": " + self.doc.account + _(" is not active"), raise_exception=1) # Account has been freezed for other users except account manager - if ret and ret[0]["freeze_account"]== 'Yes' and not adv_adj \ - and not 'Accounts Manager' in webnotes.user.get_roles(): - msgprint(_("Account") + ": " + self.doc.account + _(" has been freezed. \ - Only Accounts Manager can do transaction against this account"), raise_exception=1) + if ret and ret[0]["freeze_account"]== 'Yes' and not adv_adj: + frozen_accounts_modifier = webnotes.conn.get_value( 'Accounts Settings', None, + 'frozen_accounts_modifier') + if not frozen_accounts_modifier: + webnotes.throw(self.doc.account + _(" is a frozen account. \ + Either make the account active or assign role in Accounts Settings \ + who can do / modify entries against this account")) + elif frozen_accounts_modifier not in webnotes.user.get_roles(): + webnotes.throw(self.doc.account + _(" is a frozen account. ") + + _("To make / edit transactions against this account, you need role") + ": " + + frozen_accounts_modifier) if self.doc.is_cancelled in ("No", None) and ret and ret[0]["company"] != self.doc.company: msgprint(_("Account") + ": " + self.doc.account + _(" does not belong to the company") \