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:
commit
bd0086c1c7
@ -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}
|
||||
]
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user