From 3986badd06ab17060c5849d7d23914caec1eda11 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Fri, 26 Jul 2013 11:01:17 +0530 Subject: [PATCH] [feature] If customer/supplier account freezed do not allow to make any transaction --- controllers/accounts_controller.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/controllers/accounts_controller.py b/controllers/accounts_controller.py index abefb9bc3d..27bb2a5155 100644 --- a/controllers/accounts_controller.py +++ b/controllers/accounts_controller.py @@ -34,6 +34,8 @@ class AccountsController(TransactionBase): self.validate_value("grand_total", ">=", 0) self.set_total_in_words() + self.validate_for_freezed_account() + def set_missing_values(self, for_validate=False): for fieldname in ["posting_date", "transaction_date"]: if not self.doc.fields.get(fieldname) and self.meta.get_field(fieldname): @@ -52,6 +54,18 @@ class AccountsController(TransactionBase): if date_field and self.doc.fields[date_field]: validate_fiscal_year(self.doc.fields[date_field], self.doc.fiscal_year, label=self.meta.get_label(date_field)) + + def validate_for_freezed_account(self): + for fld in ["customer", "supplier"]: + if self.meta.get_field(fld): + accounts = webnotes.conn.get_values("Account", {"master_type": fld.upper(), + "master_name": self.doc.fields[fld], "company": self.doc.company}, + "freeze_account", as_dict=1) + + if accounts: + if not filter(lambda x: cstr(x.freeze_account) in ["", "No"], accounts): + msgprint(_("Account for this ") + fld + _(" has been freezed. ") + + self.doc.doctype + _(" can not be made."), raise_exception=1) def set_price_list_currency(self, buying_or_selling): # TODO - change this, since price list now has only one currency allowed