Added ability to freeze Customer/Supplier
diff --git a/erpnext/accounts/doctype/gl_entry/gl_entry.py b/erpnext/accounts/doctype/gl_entry/gl_entry.py
index edee122..de5b312 100644
--- a/erpnext/accounts/doctype/gl_entry/gl_entry.py
+++ b/erpnext/accounts/doctype/gl_entry/gl_entry.py
@@ -17,6 +17,7 @@
self.validate_posting_date()
self.check_pl_account()
self.validate_cost_center()
+ self.validate_party()
def on_update_with_args(self, adv_adj, update_outstanding = 'Yes'):
self.validate_account_details(adv_adj)
@@ -88,6 +89,11 @@
if self.cost_center and _get_cost_center_company() != self.company:
frappe.throw(_("Cost Center {0} does not belong to Company {1}").format(self.cost_center, self.company))
+
+ def validate_party(self):
+ if self.meta.get_field("party_type"):
+ if frappe.db.get_value(self.party_type, self.party, "is_frozen"):
+ frappe.throw("Accounts for {0} {1} is frozen".format(self.party_type, self.party))
def validate_balance_type(account, adv_adj=False):
if not adv_adj and account:
diff --git a/erpnext/buying/doctype/supplier/supplier.json b/erpnext/buying/doctype/supplier/supplier.json
index a1a38d5..0ea49a0 100644
--- a/erpnext/buying/doctype/supplier/supplier.json
+++ b/erpnext/buying/doctype/supplier/supplier.json
@@ -55,6 +55,13 @@
"reqd": 1
},
{
+ "fieldname": "is_frozen",
+ "fieldtype": "Check",
+ "label": "Is Frozen ?",
+ "permlevel": 0,
+ "precision": ""
+ },
+ {
"depends_on": "eval:!doc.__islocal",
"fieldname": "address_contacts",
"fieldtype": "Section Break",
@@ -172,7 +179,7 @@
],
"icon": "icon-user",
"idx": 1,
- "modified": "2015-07-13 05:28:29.121285",
+ "modified": "2015-07-17 02:01:36.727437",
"modified_by": "Administrator",
"module": "Buying",
"name": "Supplier",
diff --git a/erpnext/controllers/accounts_controller.py b/erpnext/controllers/accounts_controller.py
index 7610042..c893a0a 100644
--- a/erpnext/controllers/accounts_controller.py
+++ b/erpnext/controllers/accounts_controller.py
@@ -16,6 +16,7 @@
if self.get("_action") and self._action != "update_after_submit":
self.set_missing_values(for_validate=True)
self.validate_date_with_fiscal_year()
+
if self.meta.get_field("currency"):
self.calculate_taxes_and_totals()
if not self.meta.get_field("is_return") or not self.is_return:
@@ -32,6 +33,8 @@
if self.meta.get_field("taxes_and_charges"):
self.validate_enabled_taxes_and_charges()
+
+ self.validate_party()
def on_submit(self):
if self.meta.get_field("is_recurring"):
@@ -340,6 +343,20 @@
return self._abbr
+ def validate_party(self):
+ party = None
+ if self.meta.get_field("customer"):
+ party_type = 'customer'
+ party = self.customer
+
+ elif self.meta.get_field("suppier"):
+ party_type = 'supplier'
+ party = self.supplier
+
+ if party:
+ if frappe.db.get_value(party_type, party, "is_frozen"):
+ frappe.throw("Accounts for {0} {1} is frozen".format(party_type, party))
+
@frappe.whitelist()
def get_tax_rate(account_head):
return frappe.db.get_value("Account", account_head, "tax_rate")
diff --git a/erpnext/selling/doctype/customer/customer.json b/erpnext/selling/doctype/customer/customer.json
index cced319..cebfc29 100644
--- a/erpnext/selling/doctype/customer/customer.json
+++ b/erpnext/selling/doctype/customer/customer.json
@@ -102,6 +102,13 @@
"reqd": 1
},
{
+ "fieldname": "is_frozen",
+ "fieldtype": "Check",
+ "label": "Is Frozen ?",
+ "permlevel": 0,
+ "precision": ""
+ },
+ {
"depends_on": "eval:!doc.__islocal",
"fieldname": "address_contacts",
"fieldtype": "Section Break",
@@ -278,7 +285,7 @@
],
"icon": "icon-user",
"idx": 1,
- "modified": "2015-07-13 05:28:25.753684",
+ "modified": "2015-07-16 09:07:11.565841",
"modified_by": "Administrator",
"module": "Selling",
"name": "Customer",