diff --git a/accounts/doctype/purchase_invoice/purchase_invoice.py b/accounts/doctype/purchase_invoice/purchase_invoice.py index 235f34fce5..aa82492baa 100644 --- a/accounts/doctype/purchase_invoice/purchase_invoice.py +++ b/accounts/doctype/purchase_invoice/purchase_invoice.py @@ -135,13 +135,19 @@ class DocType(BuyingController): raise Exception def validate_bill_no(self): - if self.doc.bill_no and self.doc.bill_no.lower().strip() not in ['na', 'not applicable', 'none']: - b_no = sql("select bill_no, name, ifnull(is_opening,'') from `tabPurchase Invoice` where bill_no = '%s' and credit_to = '%s' and docstatus = 1 and name != '%s' " % (self.doc.bill_no, self.doc.credit_to, self.doc.name)) + if self.doc.bill_no and self.doc.bill_no.lower().strip() \ + not in ['na', 'not applicable', 'none']: + b_no = sql("""select bill_no, name, ifnull(is_opening,'') from `tabPurchase Invoice` + where bill_no = %s and credit_to = %s and docstatus = 1 and name != %s""", + (self.doc.bill_no, self.doc.credit_to, self.doc.name)) if b_no and cstr(b_no[0][2]) == cstr(self.doc.is_opening): - msgprint("Please check you have already booked expense against Bill No. %s in Purchase Invoice %s" % (cstr(b_no[0][0]), cstr(b_no[0][1]))) - raise Exception , "Validation Error" - if not self.doc.remarks: - self.doc.remarks = (self.doc.remarks or '') + "\n" + ("Against Bill %s dated %s" % (self.doc.bill_no, formatdate(self.doc.bill_date))) + msgprint("Please check you have already booked expense against Bill No. %s \ + in Purchase Invoice %s" % (cstr(b_no[0][0]), cstr(b_no[0][1])), + raise_exception=1) + + if not self.doc.remarks and self.doc.bill_date: + self.doc.remarks = (self.doc.remarks or '') + "\n" + ("Against Bill %s dated %s" + % (self.doc.bill_no, formatdate(self.doc.bill_date))) else: if not self.doc.remarks: self.doc.remarks = "No Remarks" diff --git a/accounts/doctype/purchase_taxes_and_charges_master/purchase_taxes_and_charges_master.js b/accounts/doctype/purchase_taxes_and_charges_master/purchase_taxes_and_charges_master.js index 5717bbfb25..e414c82d44 100644 --- a/accounts/doctype/purchase_taxes_and_charges_master/purchase_taxes_and_charges_master.js +++ b/accounts/doctype/purchase_taxes_and_charges_master/purchase_taxes_and_charges_master.js @@ -127,7 +127,7 @@ cur_frm.cscript.row_id = function(doc, cdt, cdn) { refresh_field('row_id',d.name,'purchase_tax_details'); } -cur_frm.set_query("account_head", "purchase_tax_details", function() { +cur_frm.set_query("account_head", "purchase_tax_details", function(doc) { return { filters: [ ["Account", "group_or_ledger", "=", "Ledger"],