From 20105d8a0d18c84543cee6e4f6aa09a80c1cc875 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Tue, 19 Jan 2016 18:05:28 +0530 Subject: [PATCH] [fix] Accept return items in any warehouse --- erpnext/controllers/sales_and_purchase_return.py | 3 +++ erpnext/controllers/stock_controller.py | 9 ++++----- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/erpnext/controllers/sales_and_purchase_return.py b/erpnext/controllers/sales_and_purchase_return.py index c6c7111851..868720a2e0 100644 --- a/erpnext/controllers/sales_and_purchase_return.py +++ b/erpnext/controllers/sales_and_purchase_return.py @@ -96,6 +96,9 @@ def validate_returned_items(doc): if s not in ref_serial_nos: frappe.throw(_("Row # {0}: Serial No {1} does not match with {2} {3}") .format(d.idx, s, doc.doctype, doc.return_against)) + + if not d.warehouse: + frappe.throw(_("Warehouse is mandatory")) items_returned = True diff --git a/erpnext/controllers/stock_controller.py b/erpnext/controllers/stock_controller.py index 842faec049..4c6a320158 100644 --- a/erpnext/controllers/stock_controller.py +++ b/erpnext/controllers/stock_controller.py @@ -218,14 +218,14 @@ class StockController(AccountsController): return serialized_items - def get_incoming_rate_for_sales_return(self, item_code, warehouse, against_document): + def get_incoming_rate_for_sales_return(self, item_code, against_document): incoming_rate = 0.0 if against_document and item_code: incoming_rate = frappe.db.sql("""select abs(stock_value_difference / actual_qty) from `tabStock Ledger Entry` where voucher_type = %s and voucher_no = %s - and item_code = %s and warehouse=%s limit 1""", - (self.doctype, against_document, item_code, warehouse)) + and item_code = %s limit 1""", + (self.doctype, against_document, item_code)) incoming_rate = incoming_rate[0][0] if incoming_rate else 0.0 return incoming_rate @@ -257,8 +257,7 @@ class StockController(AccountsController): if frappe.db.get_value("Item", d.item_code, "is_stock_item") == 1 and flt(d.qty): return_rate = 0 if cint(self.is_return) and self.return_against and self.docstatus==1: - return_rate = self.get_incoming_rate_for_sales_return(d.item_code, - d.warehouse, self.return_against) + return_rate = self.get_incoming_rate_for_sales_return(d.item_code, self.return_against) # On cancellation or if return entry submission, make stock ledger entry for # target warehouse first, to update serial no values properly