[minor] Check if item is stock item before validating Warehouse while Purchase Return (#9282)
* Check if item is stock item before validating Warehouse * changed logic to decide warehouse_mandatory
This commit is contained in:
parent
c849f647f7
commit
d19c2e2e93
@ -71,7 +71,7 @@ def validate_returned_items(doc):
|
|||||||
already_returned_items = get_already_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 )
|
# ( 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))
|
warehouse_mandatory = not ((doc.doctype=="Purchase Invoice" or doc.doctype=="Sales Invoice") and not doc.update_stock))
|
||||||
|
|
||||||
items_returned = False
|
items_returned = False
|
||||||
for d in doc.get("items"):
|
for d in doc.get("items"):
|
||||||
@ -101,8 +101,9 @@ def validate_returned_items(doc):
|
|||||||
frappe.throw(_("Row # {0}: Serial No {1} does not match with {2} {3}")
|
frappe.throw(_("Row # {0}: Serial No {1} does not match with {2} {3}")
|
||||||
.format(d.idx, s, doc.doctype, doc.return_against))
|
.format(d.idx, s, doc.doctype, doc.return_against))
|
||||||
|
|
||||||
if warehouse_mandatory and not d.get("warehouse"):
|
if warehouse_mandatory and frappe.db.get_value("Item", d.item_code, "is_stock_item") \
|
||||||
frappe.throw(_("Warehouse is mandatory"))
|
and not d.get("warehouse"):
|
||||||
|
frappe.throw(_("Warehouse is mandatory"))
|
||||||
|
|
||||||
items_returned = True
|
items_returned = True
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user