From 5b3b123fe8d4116e06f1383707166854d4d9a7f8 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Thu, 30 May 2013 17:55:16 +0530 Subject: [PATCH] Update sales_invoice.py --- .../doctype/sales_invoice/sales_invoice.py | 20 ++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/accounts/doctype/sales_invoice/sales_invoice.py b/accounts/doctype/sales_invoice/sales_invoice.py index ab44247d5ca..14a1207186b 100644 --- a/accounts/doctype/sales_invoice/sales_invoice.py +++ b/accounts/doctype/sales_invoice/sales_invoice.py @@ -444,15 +444,17 @@ class DocType(SellingController): msgprint("Customer %s does not match with customer of %s: %s." %(self.doc.customer, dt, dt_no), raise_exception=1) - def validate_customer_account(self): - """Validates Debit To Account and Customer Matches""" - if self.doc.customer and self.doc.debit_to and not cint(self.doc.is_pos): - acc_head = webnotes.conn.sql("select master_name from `tabAccount` where name = %s and docstatus != 2", self.doc.debit_to) - - if (acc_head and cstr(acc_head[0][0]) != cstr(self.doc.customer)) or \ - (not acc_head and (self.doc.debit_to != cstr(self.doc.customer) + " - " + self.get_company_abbr())): - msgprint("Debit To: %s do not match with Customer: %s for Company: %s.\n If both correctly entered, please select Master Type \ - and Master Name in account master." %(self.doc.debit_to, self.doc.customer,self.doc.company), raise_exception=1) + def validate_customer(self): + """ Validate customer name with SO and DN""" + if self.doc.customer: + for d in getlist(self.doclist,'entries'): + dt = d.delivery_note and 'Delivery Note' or d.sales_order and 'Sales Order' or '' + if dt: + dt_no = d.delivery_note or d.sales_order + cust = webnotes.conn.get_value(dt, dt_no, "customer") + if cust and cstr(cust) != cstr(self.doc.customer): + msgprint("Customer %s does not match with customer of %s: %s." + %(self.doc.customer, dt, dt_no), raise_exception=1) def validate_debit_acc(self):