From 54498452b68655189e90351c8376adc85d5c9840 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Thu, 14 Aug 2014 15:49:44 +0530 Subject: [PATCH] Stock entry minor fix --- erpnext/stock/doctype/stock_entry/stock_entry.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/erpnext/stock/doctype/stock_entry/stock_entry.py b/erpnext/stock/doctype/stock_entry/stock_entry.py index cddfd9885f..fd673a3200 100644 --- a/erpnext/stock/doctype/stock_entry/stock_entry.py +++ b/erpnext/stock/doctype/stock_entry/stock_entry.py @@ -327,7 +327,10 @@ class StockEntry(StockController): frappe.DoesNotExistError) # validate quantity <= ref item's qty - qty already returned - ref_item_qty = sum([flt(d.qty)*flt(d.conversion_factor) for d in ref.doc.get({"item_code": item.item_code})]) + if self.purpose == "Purchase Return": + ref_item_qty = sum([flt(d.qty)*flt(d.conversion_factor) for d in ref.doc.get({"item_code": item.item_code})]) + elif self.purpose == "Sales Return": + ref_item_qty = sum([flt(d.qty) for d in ref.doc.get({"item_code": item.item_code})]) returnable_qty = ref_item_qty - flt(already_returned_item_qty.get(item.item_code)) if not returnable_qty: frappe.throw(_("Item {0} has already been returned").format(item.item_code), StockOverReturnError)