diff --git a/erpnext/hr/doctype/expense_claim/expense_claim.js b/erpnext/hr/doctype/expense_claim/expense_claim.js index 65d1065fc6..f40e77c53c 100644 --- a/erpnext/hr/doctype/expense_claim/expense_claim.js +++ b/erpnext/hr/doctype/expense_claim/expense_claim.js @@ -262,27 +262,30 @@ frappe.ui.form.on("Expense Claim", { }, get_advances: function(frm) { - return frappe.call({ - method: "erpnext.hr.doctype.expense_claim.expense_claim.get_advances", - args: { - employee: frm.doc.employee - }, - callback: function(r, rt) { - frappe.model.clear_table(frm.doc, "advances"); - if(r.message) { - $.each(r.message, function(i, d) { - var row = frappe.model.add_child(frm.doc, "Expense Claim Advance", "advances"); - row.employee_advance = d.name; - row.posting_date = d.posting_date; - row.advance_account = d.advance_account; - row.advance_paid = d.paid_amount; - row.unclaimed_amount = flt(d.paid_amount) - flt(d.claimed_amount); - row.allocated_amount = flt(d.paid_amount) - flt(d.claimed_amount); - }); - refresh_field("advances"); + frappe.model.clear_table(frm.doc, "advances"); + if (frm.doc.employee) { + return frappe.call({ + method: "erpnext.hr.doctype.expense_claim.expense_claim.get_advances", + args: { + employee: frm.doc.employee + }, + callback: function(r, rt) { + + if(r.message) { + $.each(r.message, function(i, d) { + var row = frappe.model.add_child(frm.doc, "Expense Claim Advance", "advances"); + row.employee_advance = d.name; + row.posting_date = d.posting_date; + row.advance_account = d.advance_account; + row.advance_paid = d.paid_amount; + row.unclaimed_amount = flt(d.paid_amount) - flt(d.claimed_amount); + row.allocated_amount = flt(d.paid_amount) - flt(d.claimed_amount); + }); + refresh_field("advances"); + } } - } - }); + }); + } } }); diff --git a/erpnext/stock/doctype/packing_slip/packing_slip.py b/erpnext/stock/doctype/packing_slip/packing_slip.py index ec5392f99e..b99215c426 100644 --- a/erpnext/stock/doctype/packing_slip/packing_slip.py +++ b/erpnext/stock/doctype/packing_slip/packing_slip.py @@ -137,10 +137,10 @@ class PackingSlip(Document): for d in self.get("items"): res = frappe.db.get_value("Item", d.item_code, - ["net_weight", "weight_uom"], as_dict=True) + ["weight_per_unit", "weight_uom"], as_dict=True) if res and len(res)>0: - d.net_weight = res["net_weight"] + d.net_weight = res["weight_per_unit"] d.weight_uom = res["weight_uom"] def get_recommended_case_no(self): diff --git a/erpnext/stock/report/item_price_stock/item_price_stock.py b/erpnext/stock/report/item_price_stock/item_price_stock.py index 95cf3db485..4cd8fddccd 100644 --- a/erpnext/stock/report/item_price_stock/item_price_stock.py +++ b/erpnext/stock/report/item_price_stock/item_price_stock.py @@ -37,9 +37,10 @@ def get_item_price_qty_data(filters): from `tabItem Price` a left join `tabBin` b ON a.item_code = b.item_code {conditions}""" - .format(conditions=conditions),filters,as_dict=1) + .format(conditions=conditions), filters, as_dict=1) - price_list_names = ",".join(['"' + item['price_list_name'] + '"' for item in item_results]) + price_list_names = ",".join(['"' + frappe.db.escape(item['price_list_name']) + '"' + for item in item_results]) buying_price_map = get_buying_price_map(price_list_names) selling_price_map = get_selling_price_map(price_list_names) @@ -66,7 +67,8 @@ def get_buying_price_map(price_list_names): `tabItem Price` where name in ({price_list_names}) and buying=1 - """.format(price_list_names=price_list_names),as_dict=1) + """.format(price_list_names=price_list_names), as_dict=1) + buying_price_map = {} for d in buying_price: name = d["name"] @@ -84,7 +86,8 @@ def get_selling_price_map(price_list_names): `tabItem Price` where name in ({price_list_names}) and selling=1 - """.format(price_list_names=price_list_names),as_dict=1) + """.format(price_list_names=price_list_names), as_dict=1) + selling_price_map = {} for d in selling_price: name = d["name"]