From ed8d9dadfac5398a96e700a17d1a3d5271ef8127 Mon Sep 17 00:00:00 2001 From: Anand Doshi Date: Wed, 17 Feb 2016 17:14:08 +0530 Subject: [PATCH] [fix] Warehouse not mandatory for Purchase Invoice or a Sales Invoice without Update Stock --- erpnext/config/docs.py | 2 +- erpnext/controllers/sales_and_purchase_return.py | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/erpnext/config/docs.py b/erpnext/config/docs.py index 9c9c4c73de..82cb1fbfaa 100644 --- a/erpnext/config/docs.py +++ b/erpnext/config/docs.py @@ -23,5 +23,5 @@ def get_context(context): context.top_bar_items = [ {"label": "User Manual", "url": context.docs_base_url + "/user/manual", "right": 1}, {"label": "Videos", "url": context.docs_base_url + "/user/videos", "right": 1}, - {"label": "Developer Docs", "url": context.docs_base_url + "/current", "right": 1} + {"label": "API Documentation", "url": context.docs_base_url + "/current", "right": 1} ] diff --git a/erpnext/controllers/sales_and_purchase_return.py b/erpnext/controllers/sales_and_purchase_return.py index 9e0dee8e3e..ac8a5dfd70 100644 --- a/erpnext/controllers/sales_and_purchase_return.py +++ b/erpnext/controllers/sales_and_purchase_return.py @@ -67,6 +67,9 @@ def validate_returned_items(doc): already_returned_items = get_already_returned_items(doc) + # ( not mandatory when it is Purchase Invoice or a Sales Invoice without Update Stock ) + warehouse_mandatory = not (doc.doctype=="Purchase Invoice" or (doc.doctype=="Sales Invoice" and not doc.update_stock)) + items_returned = False for d in doc.get("items"): if flt(d.qty) < 0: @@ -96,8 +99,8 @@ 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 doc.doctype != "Purchase Invoice" and not d.get("warehouse"): + + if warehouse_mandatory and not d.get("warehouse"): frappe.throw(_("Warehouse is mandatory")) items_returned = True