Added ability to freeze Customer/Supplier

This commit is contained in:
Neil Trini Lasrado 2015-07-17 12:10:12 +05:30
parent 8e8e9c61ca
commit 3fbbb71afc
4 changed files with 39 additions and 2 deletions

View File

@ -17,6 +17,7 @@ class GLEntry(Document):
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 @@ class GLEntry(Document):
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:

View File

@ -54,6 +54,13 @@
"permlevel": 0,
"reqd": 1
},
{
"fieldname": "is_frozen",
"fieldtype": "Check",
"label": "Is Frozen ?",
"permlevel": 0,
"precision": ""
},
{
"depends_on": "eval:!doc.__islocal",
"fieldname": "address_contacts",
@ -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",

View File

@ -16,6 +16,7 @@ class AccountsController(TransactionBase):
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 @@ class AccountsController(TransactionBase):
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 @@ class AccountsController(TransactionBase):
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")

View File

@ -101,6 +101,13 @@
"print_hide": 1,
"reqd": 1
},
{
"fieldname": "is_frozen",
"fieldtype": "Check",
"label": "Is Frozen ?",
"permlevel": 0,
"precision": ""
},
{
"depends_on": "eval:!doc.__islocal",
"fieldname": "address_contacts",
@ -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",