Merge pull request #4826 from anandpdoshi/fix/return-warehouse-mandatory

[fix] Warehouse not mandatory for Purchase Invoice or a Sales Invoice without Update Stock
This commit is contained in:
Anand Doshi 2016-02-18 15:02:11 +05:30
commit bd0086c1c7
2 changed files with 6 additions and 3 deletions

View File

@ -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}
]

View File

@ -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