From cc7cb2a70add9f9548493b1a8f1d599358e3e7d4 Mon Sep 17 00:00:00 2001 From: Neil Trini Lasrado Date: Fri, 24 Jul 2015 13:10:50 +0530 Subject: [PATCH] Allowed frozen_accounts_modifier to create records against frozen customer/supplier --- erpnext/accounts/doctype/gl_entry/gl_entry.py | 3 ++- erpnext/controllers/accounts_controller.py | 4 ++++ erpnext/selling/doctype/customer/test_customer.py | 8 ++------ 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/erpnext/accounts/doctype/gl_entry/gl_entry.py b/erpnext/accounts/doctype/gl_entry/gl_entry.py index d3246d7554..83955ecdeb 100644 --- a/erpnext/accounts/doctype/gl_entry/gl_entry.py +++ b/erpnext/accounts/doctype/gl_entry/gl_entry.py @@ -93,7 +93,8 @@ class GLEntry(Document): frappe.throw(_("Cost Center {0} does not belong to Company {1}").format(self.cost_center, self.company)) def validate_party(self): - if self.party_type and self.party: + frozen_accounts_modifier = frappe.db.get_value( 'Accounts Settings', None,'frozen_accounts_modifier') + if self.party_type and self.party and not frozen_accounts_modifier in frappe.get_roles(): if frappe.db.get_value(self.party_type, self.party, "is_frozen"): frappe.throw("{0} {1} is frozen".format(self.party_type, self.party), CustomerFrozen) diff --git a/erpnext/controllers/accounts_controller.py b/erpnext/controllers/accounts_controller.py index cbd8a6fb82..55e9e3d000 100644 --- a/erpnext/controllers/accounts_controller.py +++ b/erpnext/controllers/accounts_controller.py @@ -346,6 +346,10 @@ class AccountsController(TransactionBase): return self._abbr def validate_party(self): + frozen_accounts_modifier = frappe.db.get_value( 'Accounts Settings', None,'frozen_accounts_modifier') + if frozen_accounts_modifier in frappe.get_roles(): + return + party_type = None if self.meta.get_field("customer"): party_type = 'Customer' diff --git a/erpnext/selling/doctype/customer/test_customer.py b/erpnext/selling/doctype/customer/test_customer.py index 2f9c4e1270..dca4bb76fb 100644 --- a/erpnext/selling/doctype/customer/test_customer.py +++ b/erpnext/selling/doctype/customer/test_customer.py @@ -68,17 +68,13 @@ class TestCustomer(unittest.TestCase): frappe.rename_doc("Customer", "_Test Customer 1 Renamed", "_Test Customer 1") def test_freezed_customer(self): - cust = frappe.get_doc("Customer", "_Test Customer") - cust.is_frozen = 1 - cust.save() + frappe.db.set_value("Customer", "_Test Customer", "is_frozen", 1) from erpnext.selling.doctype.sales_order.test_sales_order import make_sales_order so = make_sales_order(do_not_save= True) - so.customer = "_Test Customer" self.assertRaises(CustomerFrozen, so.save) - cust.is_frozen = 0 - cust.save() + frappe.db.set_value("Customer", "_Test Customer", "is_frozen", 0) so.save() \ No newline at end of file