From 466298b6e73fb40e7272499019ec19e9101a1c77 Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Fri, 14 Jun 2013 14:27:53 +0530 Subject: [PATCH] [fix] fixes in purchase common --- buying/doctype/purchase_common/purchase_common.js | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/buying/doctype/purchase_common/purchase_common.js b/buying/doctype/purchase_common/purchase_common.js index 4cf8de796c..54d8026873 100644 --- a/buying/doctype/purchase_common/purchase_common.js +++ b/buying/doctype/purchase_common/purchase_common.js @@ -225,8 +225,9 @@ erpnext.buying.BuyingController = erpnext.TransactionController.extend({ if(this.frm.doc.doctype != "Purchase Invoice") { // hack! - wn.meta.docfield_copy[this.tname][this.frm.doc.name]["rate"] = $.extend({}, - wn.meta.docfield_copy[this.tname][this.frm.doc.name]["purchase_rate"]); + var purchase_rate_df = wn.meta.get_docfield(this.tname, "rate", this.frm.doc.name); + wn.meta.docfield_copy[this.tname][this.frm.doc.name]["rate"] = + $.extend({}, purchase_rate_df); } $.each(this.frm.item_doclist, function(i, item) { @@ -310,10 +311,12 @@ erpnext.buying.BuyingController = erpnext.TransactionController.extend({ }); } - if(!wn.meta.get_docfield(item.doctype, "item_tax_amount", item.parent || item.name)) { - $.each(this.frm.item_doclist, function(i, item) { - delete item["item_tax_amount"]; - }); + if(this.frm.item_doclist.length) { + if(!wn.meta.get_docfield(this.frm.item_doclist[0].doctype, "item_tax_amount", this.frm.doctype)) { + $.each(this.frm.item_doclist, function(i, item) { + delete item["item_tax_amount"]; + }); + } } },