Allowed frozen_accounts_modifier to create records against frozen customer/supplier

This commit is contained in:
Neil Trini Lasrado 2015-07-24 13:10:50 +05:30
parent 79bf233734
commit cc7cb2a70a
3 changed files with 8 additions and 7 deletions

View File

@ -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)

View File

@ -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'

View File

@ -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()