mirror of
https://github.com/frappe/erpnext.git
synced 2026-09-14 17:33:09 +00:00
perf: don't query unless required (bp #26175)
re-order conditionals so queries are not evaluated unless required. # Conflicts: # erpnext/stock/doctype/batch/batch.py
This commit is contained in:
@@ -99,9 +99,10 @@ def validate_returned_items(doc):
|
||||
frappe.throw(_("Row # {0}: Serial No {1} does not match with {2} {3}")
|
||||
.format(d.idx, s, doc.doctype, doc.return_against))
|
||||
|
||||
if warehouse_mandatory and frappe.db.get_value("Item", d.item_code, "is_stock_item") \
|
||||
and not d.get("warehouse"):
|
||||
frappe.throw(_("Warehouse is mandatory"))
|
||||
if (warehouse_mandatory and not d.get("warehouse") and
|
||||
frappe.db.get_value("Item", d.item_code, "is_stock_item")
|
||||
):
|
||||
frappe.throw(_("Warehouse is mandatory"))
|
||||
|
||||
items_returned = True
|
||||
|
||||
@@ -462,4 +463,4 @@ def get_returned_serial_nos(child_doc, parent_doc):
|
||||
for row in frappe.get_all(parent_doc.doctype, fields = fields, filters=filters):
|
||||
serial_nos.extend(get_serial_nos(row.serial_no))
|
||||
|
||||
return serial_nos
|
||||
return serial_nos
|
||||
|
||||
Reference in New Issue
Block a user