Allowed frozen_accounts_modifier to create records against frozen customer/supplier
This commit is contained in:
parent
79bf233734
commit
cc7cb2a70a
@ -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)
|
||||
|
||||
|
@ -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'
|
||||
|
@ -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()
|
Loading…
Reference in New Issue
Block a user