From 5b7badaf207d79a5f3778ebee4135253836cdef8 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Fri, 11 Nov 2011 12:37:53 +0530 Subject: [PATCH] supplier account head validated with supplier --- .../doctype/payable_voucher/payable_voucher.py | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/erpnext/accounts/doctype/payable_voucher/payable_voucher.py b/erpnext/accounts/doctype/payable_voucher/payable_voucher.py index 9f2848ad6f..9f77935a5e 100644 --- a/erpnext/accounts/doctype/payable_voucher/payable_voucher.py +++ b/erpnext/accounts/doctype/payable_voucher/payable_voucher.py @@ -232,15 +232,11 @@ class DocType(TransactionBase): # Validate Acc Head of Supplier and Credit To Account entered # ------------------------------------------------------------ def check_for_acc_head_of_supplier(self): - acc_head = sql("select name from `tabAccount` where name = %s", (cstr(self.doc.supplier) + " - " + self.get_company_abbr())) - if self.doc.supplier: - if acc_head and acc_head[0][0]: - if not cstr(acc_head[0][0]) == cstr(self.doc.credit_to): - msgprint("Credit To: %s do not match with Supplier: %s for Company: %s i.e. %s" %(self.doc.credit_to,self.doc.supplier,self.doc.company,cstr(acc_head[0][0]))) - raise Exception, "Validation Error " - if not acc_head: - msgprint("Supplier %s does not have an Account Head in %s. You must first create it from the Supplier Master" % (self.doc.supplier, self.doc.company)) - raise Exception, "Validation Error " + if self.doc.supplier and self.doc.credit_to: + acc_head = sql("select master_name from `tabAccount` where name = %s", self.doc.credit_to) + + if (acc_head and cstr(acc_head[0][0]) != cstr(self.doc.credit_to)) or (not acc_head and (self.doc.credit_to != cstr(self.doc.supplier) + " - " + self.get_company_abbr())): + msgprint("Credit To: %s do not match with Supplier: %s for Company: %s.\n If both correctly entered, please select Master Type and Master Name in account master." %(self.doc.credit_to,self.doc.supplier,self.doc.company), raise_exception=1) # Check for Stopped PO # ---------------------